DEV Community

Cover image for Day 1:Git Branch Commands&Git Checkout Commands
Sundar Joseph
Sundar Joseph

Posted on

Day 1:Git Branch Commands&Git Checkout Commands

git branch – Display a list of the local branches in your Git repository.
git branch -a – Display a list of both local branches and remote branches in your Git repository.
git branch -c – Copy a Git branch.
git branch -d – Delete a local Git branch. This command will not work if the branch you are attempting to delete has unmerged changes.
git branch -D – Delete a local Git branch with unmerged changes.
git branch -m – Rename a Git branch.
git branch -r – Display a list of the remote branches in your Git repository.
git push --delete – Delete a remote Git branch.
git push --set-upstream – Set an upstream branch. Running this command will push your local branch to the new remote branch.

git checkout – Switch to a different Git branch.
git checkout -b – Create a new branch and switch to it.
git checkout -b / – Create a local branch from the remote Git branch and checkout that branch.
git checkout – Checkout a previous Git commit.
git checkout – Checkout a Git tag in a detached HEAD state.
git checkout -b – Checkout a Git tag as a branch.
git status – Display a list of files in your staging directory with accompanying file status.
git add – Stage file changes. Running this command with an associated file name will stage the file changes to your staging directory.
git commit – Save changes to your Git repository. Running this command with an associated file name will save the file changes to your repo.
git commit -a – Add all modified and deleted files in your working directory to the current commit.
git commit --amend – Amend a Git commit. Edit a Git commit message by adding a message in quotation marks after the command.
git commit -m – Add a Git commit message. Add your message in quotation marks following the

Top comments (0)