Skip to content

Instantly share code, notes, and snippets.

@justinhennessy
Last active December 26, 2015 02:49
Show Gist options
  • Save justinhennessy/7081269 to your computer and use it in GitHub Desktop.
Save justinhennessy/7081269 to your computer and use it in GitHub Desktop.
mycharity working with branches

To start a change on a repo with a branch

git pull
(this gets the local master branch up to date)

git checkout -b my_new_feature

You can then start working on your changes.

Once you have completed your changes do the following:

git add .

or git add -p (if you want to be careful with what you commit)

git status
(to make sure all changes are listed)

git commit -v
(-v provides you with a diff of the changes)

Write a good commit message - I suggest reading http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html

Once you have made a commit you can push to github.

git push origin feature_branch -u
(origin being github and -u you only need to do on your 
  first push so your local branch links to the remote)

You can then create a pull request by going to

http://github.com/everydayhero/mycharity
(for the most recent pushed branch look for the green compare & pull request button)

Once the pull request has been peer reviewed and merged (ideally by another person) you can then delete the branch on github.

Cleaning up locally after a merge

git checkout master

git pull

git branch
(will show you that master is selected)

git branch -d feature_branch

You can do -d to remove the branch if it's been merged. To check if something has been merged to master

git checkout master

git branch --merged

This will list master (which you are in) and the branches that have been merge and that can be safely deleted. If it hasn't been merged into master git will complain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment