Saturday 13 February 2021

GIT cheet sheet

 

Command line instructions

Note: 
If you create your repo on github / gitlab with readme.md . and have your local repo and try to do pull then you will face : fatal: refusing to merge unrelated histories.

Read this SO answer to resolve this : 

LF will be replaced by CRLF:

Complete cheat sheet :



Git global setup
git config --global user.name "Parth Pandya"
git config --global user.email "parth@gmail.com"
Create a new repository
git clone git@gitlab.com:parth/test.git
cd test
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin git@gitlab.com:parth/test.git
git add .
git commit -m "Initial commit"
git push -u origin master
Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.com:parth/test.git
git push -u origin --all
git push -u origin --tags