Cheat Sheet - git

Cheat Sheet - git

Create a new repository

git clone git@url/project.git
cd project
touch README.md
git add README.md
git commit -m "Init"
git push -u origin master

Push an existing folder

cd existing_folder
git init
git remote add origin git@url/project.git
git add .
git commit -m "Init"
git push -u origin master

Push an existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin git@url/project.git
git push -u origin --all
git push -u origin --tags

Git global setup

git config --global user.name "Giorgi Kabanashvili"
git config --global user.email "giorgi@kabanashvili.com"

Delete a Local Branch

-d stands for --delete

-D stands for --delete and --force. This option deletes the branch regardless of its push and merge status.

git branch -d branch_name
git branch -D branch_name

Checkout a Remote Branch

git checkout -t origin/branch_name

This will create a branch that is set to track the remote branch.