Tips for using Git on large teams

Here's some notes I like to refer back to when using git on a large project.  In this case there were many branches simultaniouysly under development and all being pushed into master after testing.  Checking bad code into master could cause big issues for other developers so we had to be careful.

I feel like sytax of some of these commands can be a little misleading.  Knowing what origin actually means is important, as illustracted by these two commands which are essentially the same thing.

git push origin remote_branch_name
git push origin local_branch_name:remote_branch_name

Your coworker might create a new local branch then push it up to the remote "origin" like so..

git branch DEV1234				//create new branched based of the branch you're currently in
//make some updates
git push -u origin DEV1234 //send this branch up to origin so others can access it as well

You might pull it down locally like so.  This creates a local space called DEV1234 which is pointing at origin/DEV1234

git checkout DEV1234

Be careful with "git push"!  Default behavior (at least for the version we were using), is to push all local branchs up to the remote.  Often times I didn't want those branches there (espeically if I was screwing around in master locally).  Push a specific branch like so..

git checkout DEV1234
git push origin DEV1234

Here's a tip, most of the developers I worked with would stash changes before a rebase or pull, it's usually less finky than merging and you don't end up with all those ugly merge messages.  So if i need to pull somebody elses changes into my version of the branch we were both developing, I'll do something like this

git stash
git pull origin DEV1234
git stash apploy stash@
// and if there were conflics we usually fixed them with an editor, i used Intellij

Get the latest changes from the remote branch and for your local to update to it

git fetch origin
git reset --hard origin/branchname

Sameple workflow for bringing your branch up to date with master before merging into master.

git checkout master
git pull
git checkout asdf1234
git rebase master
//status will now say you are ahead or something similar
touch asdf.txt
git status
git commit -a
git checkout master             //then back to master
git merge master asdf1234
git push