Useful Git Commands
29. July 2014

Repo Handling

Create a new repo inside the actual directory

git init

Clone an existing repo locally

git clone <host>:<repo>

Push your version of the master branch into the repo

git push origin master

Add remote location to local repo

git remote add origin <host>:<repo>

Push a locally locally created branch to origin

git push -u origin <branch-name>

Modify remote url ( to use ssh instead of https f.e.)

git remote set-url origin [email protected]:icinga2.git

Show local/remote branches

git branch -v (lokal)
git branch -r (remote)

Switch to a branch

git checkout -b <branch name>

Add local tracking branch for remote branch from origin and goto it

git branch <branch-name> origin/<branch-name>
git checkout <branch-name>

Create a pull request for single commit in github

git remote add upstream <git repository>
git remote update
git checkout -b upstream upstream/master
git cherry-pick <SHA hash of commit>
git push origin upstream
(change to upstream branch on github and create your pull-request)



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.