Friday, March 20, 2015

Commands

Commands

Create and switch to a new branch 

git checkout -b [name_of_your_new_branch]

delete a local branch in git

git branch -d [name of the branch]

create a new branch and track it with a remote branch

git checkout -b [name of new branch] -t [origin/<name of remote branch>]

delete last commit 

git reset --soft HEAD~1

renaming a branch

git branch -m <oldname> <newname>

renaming current branch

git branch -m <new name>

see code changes in last two commit

git log -p -2

Cloning a git repository (after setting up ssh key pair)

git clone git@github.com:<userID>/<repository>.git

git clone git@github.com:coderetriever/Android.git

Creating a new repository on the command line

echo "# HTML5" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:coderetriever/HTML5.git
git push -u origin master

Push an existing repository from the command line

git remote add origin git@github.com:coderetriever/HTML5.git
git push -u origin master


0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home