Git(Hub) tips - mhulse/mhulse.github.io GitHub Wiki

Feature branch push

# In feature branch ("ui-start" for example):
$ git co ui-start
# Make changes here, then:
$ git status
$ git add .
$ git commit -a # Opens vim to do long commit message; first line is where you'd put issue number.
# Add lines to top of open file.
# Use :wq to exit (write and quit)
# Or, short commit message:
$ git commit -am 'Short commit message goes here'
$ git co master
$ git fetch upstream
$ git rebase upstream/master
# Go back to your feature branch:
$ git co ui-start
$ git log
$ git push origin ui-start

Catching up

$ git status
$ git fetch upstream
$ git co master
# If you have local uncommited changes that you don’t care about:
$ git co . # Nukes everything.
$ git co master
$ git rebase upstream/master
$ git push origin master
$ git lg # View log

Working with origin/master upstream repo

Clone repo locally.

Fork repo on GitHub or BitBucket.

Next, edit the locally-cloned repo’s config:

[remote "origin"]
	url = [email protected]:mhulse/REPO.git

Or just fork, then clone your fork and skip the above step.

$ git remote add upstream [email protected]:USER/REPO.git
$ git remote show
$ git fetch upstream
$ git checkout -b NEW-BRANCH-NAME
$ git add .
$ git commit -am 'COMMIT MESSAGE HERE'
$ git checkout master
$ git rebase upstream/master
$ git merge NEW-BRANCH-NAME
$ git push origin master

Once fork has been merged:

$ git fetch --all
$ git rebase upstream/master
$ git push origin master
$ git remote update && git status

Update local fork with upstream/original

$ cd repo/
# Verify:
$ git remote -v
# Add upstream:
$ git remote add upstream
# Verify:
$ git remote -v
# Fetch:
$ git fetch upstream
# If not already, switch to master:
$ git checkout master
# Merge:
$ git merge upstream/master
# Check status:
$ git remote update && git status

At this point, you’ll want to commit/sync any changes you just pulled from upstream.