Skip to content

Latest commit

 

History

History
99 lines (69 loc) · 2.09 KB

cheatsheet-git.md

File metadata and controls

99 lines (69 loc) · 2.09 KB

GIT Cheat sheet

"Good to Know" overview

Links


Useful setup commands

git config --global user.name "Your Name Comes Here"
git config --global user.email [email protected]


Basic Git commands

Checkout out a repository from remote source

git clone url

Get Updates from repository server and merge them in local checkout

git pull

Initialize a repository

git init
git add .
git commit

Get a status of changed files/folders

git status

Applying a patch

git apply

To restore a file from the last revision

git checkout path

Adding / Updating / Deleting / Moving -

git add file
git rm file
git mv file

Committing changes to repository

git commit -a -m "Commit Msg"

Look for changes in the repository

git log
git blame file

See contents of a file, listing of directory or commit

git show rev:path/to/file
git show rev:path/to/directory
git show rev


Tagging and branching

Create a tag

git tag -a name

List a tag + list tag msg

git tag -l git tag --list git show tag

Delete a Tag

git tag -d "123"

Delete a Tag remote origin

git push origin :refs/tags/123

Create and use a branch

git branch branch
git checkout branch

Get a list of branchnames

git branch

Move tree to a older revision

git checkout rev
git checkout prevbranch


Git + Remote commands

Switching to a remote branch

git checkout --track -b branch origin/branch

Show the remote repositories

git remote show
git remote show origin