git tips and tricks
TRANSCRIPT
Git Tips and Tricks
Disclaimer
• Not designed for someone who’s never used git before
• Designed for someone who is using it on a day-to-day basis, but want to know more about features available
• Only showing command-line approach
So what is git?
• Version Control System (VCS)• Allows you to store versions of a set of files• The change from one version to the next
version is a commit
3
git add -p
• Confirm each change before staging it for the next commit
• No more binding.pry in commits!
4
git stash save
• Save changes without adding them as a commit
• Useful if you need to change what you’re working on, or have too many changes for a single commit
6
Step 1: Too many changes
Step 2: Stage and commit one change
Step 3: Stage and commit other change
git blame
• Show when a line was last edited, and who did it
• (You can get the “why”, the commit message, with some extra parameters)
10
git log -p
• Don’t just provide the commit message:– SHOW ME TEH CODEZ
12
git commit --amend
• Something was wrong with the last commit:– You forgot a semicolon– You forgot a file– You need to change the commit
message
14
git reset --soft
• Sometimes, you’ve made a couple of commits, but they’re not that important. Just turn them into a single large commit.
16
git rebase -i
• Warning: Serious rewriting of history possible
18
git rebase -i (continued)
• This will show the safest scenario possible
19
Result
git bisect❖Find out what broke the build