Skip to main content

Commands

Config​

  • git config --list
  • git config --global user.name “user-name”
  • git config --global user.email “example@mail.com”
  • git config --global core.editor code
  • git config --global push.default matching
  • git config --global core.excludesfile ~/.gitignore_global

Create​

  • git init
  • git clone [remoteurl] [directoryname]

Check Status​

  • git status

Stage file​

  • git add .
  • git add <path>
  • git add -p

Staged file​

  • git diff --staged

Add changes​

  • git add [folder]/*

Commit changes​

  • git commit -m “Commit message”

Pull changes from remote​

  • git pull

Remote​

  • git remote rm [origin]
  • git remote -v
  • git remote add origin [remote git url]

Branching​

  • git branch
  • git branch -m [newname]
  • git branch -m [oldname] [newname]
  • git checkout -b [newbranch] [createfrom]
  • git push --set-upstream origin [branchname]
  • git push origin :[branchtodelete]

Tagging​

  • git tag [tagname]
  • git tag -a [tagname] -m “[message]”

Push​

  • git push
  • git push [remotename] [branchname]
  • git push -u origin --all
  • git push -u origin --tags

Change Author​

git filter-branch -f --env-filter ”
GIT_AUTHOR_NAME=‘Nirbhay Singh Rao’
GIT_AUTHOR_EMAIL=‘nirbhay@live.in’
GIT_COMMITTER_NAME=‘Nirbhay Singh Rao’
GIT_COMMITTER_EMAIL=‘nirbhay@live.in’
”HEAD

References​