- Cheat Sheet and Example is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools







Git - How to use Git.


  • Git is a distributed revision control and source code management (SCM) system.
  • Git is a version control system (VCS) for tracking changes in computer files and coordinating work on those files among multiple people.

Web Sites

Deploy Image with Git

Deploy Image with Git

Git Flow Image

Git Flow Image



Command Explanation Example
git --version Disaplay git version
git config --list
git config -l
git config
Git Configuration Example
~]$ git config --global XXXXX
~]$ git config --global
~]$ git config --global --list   <- check
~]$ cat ~/.gitconfig

Setting Up a Git Repository

Command Explanation Example
git init Create an empty Git repository or reinitialize an existing one git init
git init --bare project1 ← --bare: Create minimum reposibotry
git init --bare --share project1 ← --share: Permit push with same GID
git clone git clone project1 testclone
git clone
git clone ssh://
$ git clone
$ ls -l project-name

git remote
Command Explanation
git remote
git remote -v
list remote repository
git remote add NAME URL
git remote add origin
Register remote repository with local repository
git remote show NAME
git remote show origin
show remote repository with detail
git remote rename OLDNAME NEWNAME
git remote rm NAME
git remote rm origin
$ git init
$ git add -A
$ git commit -m "message"
$ git remote add origin

$ vi xxxxx

$ git add -A
$ git commit -m "message"
$ git push

Daily Work

Command Explanation Example
git pull Update local repogitory from remote repogitory git pull [remote repository PATH] [branch]
git pull origin master
git add Add file contents to the index git add test.txt
git add -p ← all files of changed
git add . ← new add and edit files
git add -u ← delete files, edit files, not new files
git add -A or git add -all ← both . and -u
git rm git rm -f test.txt
git commit Record changes to the repository git commit -m “message”
git commit -a ← only changed files, not new file
git status Show the working tree status
git push git push [remote repository PATH] [branch]
git push
git push origin master
← Push to master branch of remote repository called origin
git diff git diff ← between index and working
git diff --cache ← between HEAD and index
git diff [commit id 1] [commit id 2]
git log Show commit logs git log
git log --until=2017-01-18 / git log --before=2017-10-15
git log --after=2017-01-20 / git log --since=2017-10-15
git log --grep='XXXX'
git log --oneline
git log --graph --decorate --oneline
git checkout Cancel edits (before adding) git checkout .
git checkout -f master
git revert git revert HEAD
git reset
git clean Remove untracked files from the working tree git clean -n ← check only(dispalay a deleting files. not delete)
git clean -df ← directory adn file
git clean -xf


Command Explanation Example
git branch -a Check Branch
git branch NEW Crate Branch
git checkout BRANCHNAME Change Branch


Cancel edits (before adding)

git checkout  FILE
git checkout  DIRECTORY
git checkout  .         <- all files

Returns version of commit

git reset  --hard  COMMITID

Check the commit id with the git log command

git checkout COMMITID FILE


Case sensitive

differentiating between capital and lowercase letters.

$ git config -l --local | grep core.ignorecase
$ git config core.ignorecase false
$ git config -l --local | grep core.ignorecase
How to Change

middleware/version-control/git/index.html.txt · Last modified: 2020/06/07 by admin

Page Tools