Git Assignment Sayan
Git Assignment Sayan
Roll - 152402011
ii. Check in a quick way how many commits were made by your user in 'wc1':
• git shortlog
Exercise 13 - Daisy's Diary
13. Look at the changes for "logo.css" from reflog:
i. In general ( git reflog )
ii. For a concrete branch
17. In 'wc3', create the branch 'beastFutureEwer' ( git branch , git checkout )
i. In 'beastFutureEwer':
• Change 'logo1.html', go back to 'master' and check status, then switch back to
'beastFutureEwer'
• Stage your changes, go back to 'master' and check status, switch back to
'beastFutureEwer'
• Commit changes, go back to 'master' and check status, switch back to
'beastFutureEwer'
• Watch changes in gitk ( gitk --all & ), push changes (?), pull changes (?)
• Change the height of the picture in 'logo.css' to '150px'
• Commit changes
• Check the history, go back to 'master' and check history again. Any conclusions?
ii. In 'master' apply changes:
• In 'logo.css', change the height to '200px'
• Commit changes
• Add a new row in the table in 'logo1.html' and commit this change, watch it in gitk
(refresh with F5)
• Check the history, send changes to the remote repo
• Watch it again with gitk (F5)
Exercise 18 - Tree Monkeys Continued
18. Combine changes from the main branch with 'beastFutureEwer':
• pwd , git merge
i. Create 3 new branches:
• Start them in 3 different revisions in master
• Have at least 2 revisions in each
• Merge them into master in one step ( git merge )
ii. Create 2 new branches:
• First one starts in master
• Second one starts in the first one
• Merge them into each other in reverse order (two steps)
iii. Reverting a merge:
• Create a simple branch with one revision only and merge it into 'masta'
• Undo it
◦ git log --all --branches --graph
◦ git reflog
◦ gitk --all &
◦ git reset(?)
◦ git revert(?)
iv. Pushing branches:
b. In 'wc2':
• Do the same two operations as in (1) but use names 'reby' and 'rebaser'
• Combine those 2 branches with 'rebase' (rebaser on top of reby)
c. Use gitk --all & to compare both ways.
viii. Reverting 'rebase':
• git reflog
• git reset
25.1. In 'wc1':
• Change logo.html
• Add new file mniam
• Clean working copy
(git clean, git checkout)
25.2. In 'wc2':
27a. In 'wc1':
Exercise 28 - Externals
28. (git submodule)
http://training-course-material.com/training/Git_-_Submodules
cd ~/s
git clone --bare subtr subtr.git
cd ~/s/subtr
git remote add origin ~/s/subtr.git
git push --set-upstream origin master
cd ~/s
mkdir mainproj
cd mainproj
echo "mainproj" > mainproj
git init
git add .
git commit -m "mainproj"
cd ~/s
git clone --bare mainproj mainproj.git
cd ~/s/mainproj
git remote add origin ~/s/mainproj.git
git push --set-upstream origin master
cd ~/s/subtr
echo "ch1 in subtr" >> .\subtr
git commit -am "ch1 in subtr"
git push
cd ~\s\mainproj\
echo "ch 1 in main" >> .\mainproj
git commit -am "ch1 in main"
git checkout subtr
git pull
29b. In 'wc2':
• Get changes from the remote repo, but without using pull
◦ Go to .git/ and look at the content of FETCH_HEAD
29c. Combine changes with the main branch and send them to the remote repo
(git fetch, git merge)
Exercise 30 - No Secrets in Git Objects
30a. In 'wc3':
1. In wc2 :
• Edit a .png file in 'Inkscape' and save it as test.svg
• Add test.svg to the tracked list of ignored files ( .gitignore )
• Send changes to the repo.
2. In wc1 :
• Edit the logo1.html file in the gedit program and change all occurrences of 'blindZ' to
'up'
• Do not save changes yet
• Ensure that gedit will automatically back up the file
• Add a copy to the non-traced list of ignored files ( .git/info/exclude )
• Send changes to the repo.
3. Clone the repo into wc3 and compare both ignore paths:
• Edit a .png file in 'Inkscape' and save it as source.svg
• Edit the logo2.html file in gedit and change all rotations to 'down', wait for a backup
• Check the state of wc3 , what can you say?
• Send changes to the repo.
Exercise 34 - Listing Files with Context
34. List files in wc2 that are:
• Deleted
• On the stage
• Ignored
• With additional info about changes in cache
• Use git ls-files
Exercise 35 - Being a Good Pimp with Git
35. Hooks.
1. In wc1 :
• Create a pre-commit hook that checks if the word 'notFixedYet' exists in staged changes
and prevents committing such a change.
• Copy pre-commit.sample into pre-commit in the .git/hooks folder.
• Make sure it is executable.
• Prepare the proper bash code.
• Change logo.css with /* notFixedYet */ .
• Change logo.html and type "Fixed".
• Try to commit with git commit -a .
• Use a simple commit.
• Any conclusions?
• Send changes to the remote repo.
2. In wc2 :
• Update the repo.
• Add /* notFixedYet */ in logo.js .
• Commit changes.
• What can you say?
• Fix it!
35.1. Post-Hook
1. In wc3 :
• Create a post-hook that queries a MySQL database with a simple query
( SELECT * FROM table_name ), but only when someone switches between branches.
Useful Aliases