Skip to content

Instantly share code, notes, and snippets.

@nirajgiriXD
Last active September 1, 2024 05:05
Show Gist options
  • Save nirajgiriXD/71147f2215dd74df0fb5f35dce9c7979 to your computer and use it in GitHub Desktop.
Save nirajgiriXD/71147f2215dd74df0fb5f35dce9c7979 to your computer and use it in GitHub Desktop.
Useful Git commands

Git Commands

git add .
git branch <branch-name>
git branch -a
git branch -m <old-branch-name> <new-branch-name>
git checkout <branch-name>
git checkout <commit-hash> -- <file/to/restore>
git checkout -b <branch-name>
git checkout -b <new-branch-name> staging
git cherry-pick <commit-hash>
git clean -f
git clone <repo-name>
git clone <repo-name> .
git commit -a --allow-empty-message -m ''
git commit -am <commit-msg> --force
git commit --amend -m <new-ammend-message>
git commit -m <commit-msg>
git commit -m <commit-msg> -m <commit-description>
git commit -m <commit-msg> --force
git commit -m <commit-msg> --no-verify
git commit --allow-empty --allow-empty-message -m ''
git config --global core.autocrlf input
git config --global core.autocrlf true
git config user.email <email>
git config user.name <username>
git diff
git diff <branch> --no-prefix > path/to/dir/filename.diff
git fetch
git fetch origin
git init
git log
git merge <branch-name>
git pull <repo-name>
git push -d origin <branch-name>
git push origin <branch-name>
git remote add <origin-two> <git-repo-ssh>
git remote remove <origin>
git remote set-url origin <new-origin-url>
git remote -v
git reset <file/to/reset>
git reset --hard <commit-hash>
git reset --soft <commit-hash>
git revert <commit-hash>
git stash
git stash clear
git stash pop
git status
git submodule add <repository_url> <path>
git submodule init
git submodule status
git submodule sync
git submodule update
git submodule update --init --recursive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment