UN-LEARN • Un-sophisticated UI clients • Git CLI is cool and friendly. Use It! • Git is not a server by itself. • That’s unlike SVN, CVS, etc. • But, that’s okay - really!
data • doesn’t have any attributes • .. not even file name • renaming file doesn’t change this object • its location independent (in directory tree) • Want to see blob contents? git show <sha_of_blob> 4 Object Types - The Blob
• a description of how we got there (link to parent) and • why (the commit message) • Want to not just see but examine your Commit? git log --pretty=raw git show -s --pretty=raw <sha_of_commit> 4 Object Types - The Commit
to .gitignore, I hurriedly added them to index (staging area). $ git add -A . $ git status # On branch my_pet_feature # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # new file: errors.log # new file: out.log Now.. what do I do? QUIZ (Shit that happens..)
$ git rm --cached *.log $ git status # On branch my_pet_feature # Untracked files: # (use "git add <file>..." to include in what will be committed) # errors.log # out.log
HEAD^ $ git status # On branch my_pet_feature # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # modified: abc.txt # new file: errors.log # new file: out.log $ git rm --cached *.log $ git status # On branch my_pet_feature # Untracked files: # (use "git add <file>..." to include in what will be committed) # errors.log # out.log Alternatively: $ git reset HEAD^ $ git status # On branch my_pet_feature # Untracked files: # (use "git add <file>..." to include in what will be committed) # errors.log # out.log
2. Show me the last 2 commits git log -2 3. Show me the patch introduced with each commit git log -p 4. Show me just the commit messages git log --pretty=oneline git log --oneline
last 2 weeks git log --since=2.weeks 2. Show me the commits before 3 months git log --before=3.months 3. Show me the commits authored by ‘karthik’ only git log --author=karthik 4. Show me just the commit where the commiter is ‘karthik’ git log --committer=karthik
me commits made during the first two days of this week git log _______________________ 2. Show me the commits made since the last half hour git log _______________________ 3. Show me the commits authored by ‘karthik’ for the last 10 days git log _______________________ 4. Show me just the commits where the commiter is ‘karthik’ and author is ‘ganesh’ git log _______________________ 5. I’ve a commit (with sha a1fix) to fix a high priority bug in Production. I need to merge these changes in other developmental branches as well. What is the efficient way to do it? 6. I’ve made some really bad local commits in my feature branch. Can I undo it?
2. http://git-scm.com/book (FREE online version of Pro Git) 3. http://git-scm.com/docs 4. http://try.github.io (Got 15 minutes and want to learn Git?) 5. Git in the Trenches by Peter Savage (http://cbx33.github.io/gitt/) 6. https://git.wiki.kernel.org/index.php/GitSvnComparsion 7. http://blog.jessitron.com/