Skip to content

Help page for git commands

Command to setup username for git commit

git config --global user.name "<username>"

Command to setup email for git commit

git config --global user.email "<email>"

Command to add a remote git repository URL to local git repository

git remote add <name to identify the remote> <remote git repository url>

Command to cleanup untracked or temproary files from a git repository

git clean -x -d -f

Command to check the commit list

git log

Command to amend the last commit message

git commit --amend -m "New commit message"

Command to revert the last unpushed commit

git reset HEAD~1

Command to display the current configurations of a git repository

git config --list
core.autocrlf = true for Windows
core.autocrlf = input for Linux

Use the below command to set this:
git config --global core.autocrlf = <value>

Command to check difference of a file from current to another branch

git diff <another-branch> -- <file-path>