DEV Community

Cover image for Git Commands Cheat Sheet

Git Commands Cheat Sheet

mrdanishsaleem profile image Danish Saleem ・Updated on ・1 min read

git init - Create a new Git repository

git clone - Clone a repository

git status - Show state of current directory

git log - List the commit history

git diff - diff b/w working directory & index

git show - Display the content and metadata

git branch - List all branches in the repository

git checkout [branch] - Switch to a branch

git branch -d - Delete a Branch

git branch -m - Rename a branch

git merge [branch] - Merge the specified branch

git add [file] - Stage changes

git add . - Stage everything

git revert [file] - Undo changes

git clean -n - Show untracked files

git commit --amend - Replace the last commit

git remote add - connection to a remote repository git pull Fetch a repository

git push - Push a branch

git config --global - Define the author name to be used

git reset - Reset staging area to match most recent commit

git fetch - Fetches a specific from the repo.

Well this all I know if you know more git commands then kindly comment them below. Thanks 😊

Buy Me a Coffee

Discussion (0)

Forem Open with the Forem app