Introduction To GIT-1
Introduction To GIT-1
• ~/.gitconfig
• .git
In top level of repository
Contains all objects, commits, configuration,
for project
.git/config has project specific configurations
• .gitignore
Stored in directory for ignoring
Working With Git
• echo “I love Git” >> hello.txt
• git diff
Shows changes we have made
• git status
Shows list of modified files
• git add hello.txt
• git diff
No changes shown as diff compares to the index
• git diff HEAD
Now can see the changes in working version
• git status
• git commit -m ‘Second commit’
Viewing What Has Changed
• git log
Note the hash code for each commit.
• git show <OBJECT>
Can use full or shortened hash
• git reflog to see all changes that have
occurred
Git and Patch files
• git diff HEAD^^
Show what has changed in last two commits
• git diff HEAD~10..HEAD~2
Show what changed between 10 commits ago and two
commits ago
• git format-patch HEAD^^..HEAD
Will create individual patch files per commit
• git apply to apply patches
git am to apply patches from an mbox
• Can also compare
Between specific objects
To branches/tags
Undoing What is Done
• git checkout
Used to checkout a specific version/branch of the tree
• git reset
Moves the tree back to a certain specified version
Use the --force to ignore working changes
• git revert
Reverts a commit
Does not delete the commit object, just applies a
patch
Reverts can themselves be reverted!
• Git never deletes a commit object
It is very hard to shoot yourself in the foot!
Git and Tagging
• Simple branching
o--o--o <-- origin
\
a--b--c <-- mywork
Rebasing Example
• bash/zsh completion
• Gitk
GUI to review changes
• git instaweb
Used for starting HTTP process for browing
project
Further Resources
• http://git.or.cz/
http://git.or.cz/course/cvs.html (For CVS users)
http://git.or.cz/course/svn.html (For SVN users)
• http://www.kernel.org/pub/software/scm/git/docs/
user-manual.html
• http://jonas.iki.fi/git_guides/HTML/git_guide/