Git cli

Jump to: navigation, search


Create a new repository on the command line

git init
git add
git add .
git commit -m "first commit"
git remote add origin ssh://
git remote add origin
git push -u origin master

Push an existing repository from the command line

git remote add origin ssh://
git push -u origin master

Clone repository

git clone ssh://

List remote repositories

git remote -v

Compare commits

git diff
git status


List branches

git branch
git branch -v # Display branch and last commit

Create branch

git branch newbranch

Switch branch

git checkout newbranch

rename branch

#current branch
git branch -m newbranchname
#other branch
git branch -m <oldname> <newname>

Push new local branch

git push -u origin newbranch

Merge branches

git checkout master
git merge newbranch

Delete branches

# locally
git branch -d new_branch 
git push origin --delete new_data_model


useful commands

# List commits
git log

#delete commit
git reset HEAD^
git revert HEAD^


Useful links

techUnit's cofounder