Skip to content

Instantly share code, notes, and snippets.

@calebsmith
Created April 15, 2015 14:55
Show Gist options
  • Save calebsmith/0d6858ac52f57509e97a to your computer and use it in GitHub Desktop.
Save calebsmith/0d6858ac52f57509e97a to your computer and use it in GitHub Desktop.
Git cheat sheet
Clone another's repo, branch and merge
#Ask to be made a "contributor" so you can commit directly to their repo
git clone [email protected]:calebsmith/fn.py.git
# Can work as normal on the master branch, *or* create a branch (if feature/bug fix is mostly orthogonal)
Creating branches
git checkout -b mybranchname
#....work
git add .
git commit -m 'added feature x'
git push origin mybranchname
# when ready to merge in and share with everyone on the team
git checkout master
git pull origin master
git merge mybranchname
git push origin master
Work on and see your teammate's branches
#After they have committed and pushed their branch with (git push origin branchname)
# You are currently on master
git checkout -b branchname
git pull origin branchname
# Now you have their code. can merge in if desired with:
git checkout master
git pull origin master
git merge branchname
# It is merged, let's update the upstream for everyone
git push origin master
Update feature branch with upstream changes (My teammate changed master, my branch was made off of an old master)
git checkout master
git pull origin master
git checkout mybranchname
git merge master
git push origin mybranchname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment