Git Cheatsheet

List of basic Git commands to use.

Initialise
git –version
git init repo_name: initialise repo
rm -r .git: remove git
rm -r repo_name/.git: remove git


Commit
nano README
git add README
git commit -a -m “message here”
-a: all
-m: message
git add: add files one at a time


Status & Log
git status
git log: log of all commits
git checkout 1ab2c
git diff 1ab2c 2de3f


Branch
git branch new_branch
git checkout -b new_branch
git checkout branch_name
git commit -a -m “message”
git branch: list branches in repo
git branch -D branch_name: delete branch


Merge
git checkout master
git merge branch_name


git conflict:
<<<<<< HEAD
abcdefg.
======
hijklmnop.
>>>>>> branch_name
edit & merge:
abcdefg.
hijklmnop.


commit:
git add file_name
git commit


Remote
git clone ~/repo_name your_repo_name
git remote: see all remote repo
git remote add: add new remote repo to current repo


git commit -a -m “message here”
git push origin branch_name


git pull origin branch_name
git push

Leave a Reply

Your email address will not be published. Required fields are marked *