My Git Hub Shortcuts

Fork

http://help.github.com/fork-a-repo/

git clone git@github.com:username/Spoon-Knife.git

cd Spoon-Knife
git remote add upstream git://github.com/octocat/Spoon-Knife.git
git fetch upstream

 

Committing Changes

# To commit changes to local repository
git commit -a

# Send changes to remote repository:
git push origin master

 

Update a Forked Repository

#Fetches any new changes from the original repo
git fetch upstream

# Merge changes retrieved from the fetch
git merge upstream/master

 

Creating a Branch

# Creates a new branch called "mybranch"
git branch mybranch

# Switch to mybranch
git checkout mybranch

# Merge changes from mybranch into master and delete mybranch
git checkout master
git merge mybranch
git branch -d mybranch

# Delete remote branch after local delete
git push origin :mybranch

 

Getting a Remote Branch

http://stackoverflow.com/questions/1897475/github-how-to-checkout-production-branch

# To list branches:
git branch -a

#You could checkout directly the remote branch after fetching it
git fetch origin
git branch -f remote_branch_name origin/remote_branch_name
git checkout remote_branch name

# or shorter:
git checkout -b production origin/production

# Merge changes from remote production into local production
git co -b production
git pull origin production

Tagging

#Create local tag
git tag -m"Tag version 1.0" V1.0 

# Push tag to origin
git push --tags

Merge Patch Request Locally to Test it Out

# Every pull request has a .patch URL where you can grab a textual patch file to feed into the git-am command
$ git checkout master
$ curl http://github.com/github/jobs/pull/25.patch | git am
$ git push origin master

 

Leave a comment

0 Comments.

Leave a Reply


[ Ctrl + Enter ]