Branching helps you try out new features while leaving a copy of your existing codebase intact. This is nice for working on teams, because it lets each team member work on a different section of code, without them having to sift through the changes the other team members are making at the same time (as displayed by "git diff".)
Diff is for difference. When you tell your terminal " git diff 'master' ", you're telling git to show you the differences between your working directory (the branch you've checked out) and the master branch.
The process goes something like this. In the terminal, from your working directory:
git checkout -b "name_of_new_branch"
[Go to text editor, make changes to your code]
git diff "master"
At this point, the terminal summarizes the differences for you. A few helpful hints:
- @@ marks one changed section. (In addition to the lines you changed, diff shows you the lines surrounding them, to give you some context.)
- - marks the lines you removed (or made changes to)
- + marks the additions or changes you made (on your new branch)
When you're done making changes (you've completed your new feature or whatever,) you switch back to the branch you were on before -- say, "master" :
git checkout "master"
And use "git merge [branch]" to apply your changes:
git merge "name_of_new_branch"
If you're done using the branch you made, you can delete it:
git branch -d "name_of_new_branch"
Rinse and repeat.