Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save thadeusdev/63da55e4799e6d03df2ce40f0a0e444d to your computer and use it in GitHub Desktop.

Select an option

Save thadeusdev/63da55e4799e6d03df2ce40f0a0e444d to your computer and use it in GitHub Desktop.
Simple Git workflow for collaborating on a project. I wrote this to help a co-worker learn Git (and help me remember after a year of working on my own).

Creating the change

$ git checkout -b my-feature

... modify code ....

$ git add <filename> 
$ git commit -m “my feature is this”

... or, if you're lazy ...

$ git commit -a -m "my feature is this"

... then pull in changes from master since we branched, and re-apply ours on top...

$ git pull
$ git rebase master  

... resolve conflicts (if any) and add them ...

$ git add <filename>
$ git rebase --continue

... # push my branch back to the server

$ git push origin my-feature 

Other guy merges in the changes

$ git pull 

... list branches

$ git branch -a

... bring a branch local

$ git branch --track my-feature origin/my-feature
$ git checkout master
$ git merge my-feature

... resolve conflicts and look around ...

$ git push

... delete branch (and remote branch) when done

$ git branch -d my-feature 
$ git push origin :my-feature 

Other useful commands

To remove remote branches from your list after they have been deleted by other people

$ git remote prune origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment