My Git Workflow

      2 min read           · ·

Working on a large team of developers can be difficult when trying to keep code, branches, and repositories in sync. Here are a few things that I have found helpful.

  1. Branch from master
  2. If you are using a ticketing/bug-tracking system, use the ticket/bug identifier in the branch name git checkout -b ticket-1234
  3. Keep your branch up-to-date by syncing master to it frequently git fetch && git merge master
  4. Commit to your branch frequently. The smaller you keep your changes, the safer it is to do this. git commit -am "some really small change"
  5. Push to your remote Git repo as soon as you have a viable MVP (AKA something that doesn’t break) git push origin ticket-1234
  6. If you are in the Github ecosystem, use Hub to submit your pull-request hub pull-request
  7. After your P/R is accepted, remove it from the remote repository git branch --merged master | grep -v master| cut -d/ -f2- | xargs -n 1 git push --delete origin
  8. Then remove it from the local repository git branch --merged master| grep -v master | xargs -n 1 git branch -d && git update-ref -d refs/origin/master

Now, some may argue that syncing with master frequently leads to merge-conflicts. My response:

Conflict is a fact of life. Get over it. ~ Me

Seriously, the longer you wait to the address merge conflicts, the worse the process becomes. Several small updates are a lot less painful than one long update that can take hours to unravel depending on the size of the changes and the size of your team.

NOTES:

Disagree? Did I miss something? Comment below or you can Tweet me with #git .
comments powered by Disqus