DEV Community

Himanshu Gupta
Himanshu Gupta

Posted on

Here are Top Git commands

Here is Git some Basic Command which is more comman to use with name and short description.

git init - Initializes a new Git repository
git clone [repository] - Clones an existing repository to your local machine
git add [file] - Adds a file to the staging area
git rm [file] - Removes a file from the repository
git mv [file-original] [file-renamed] - Renames a file in the repository
git commit -m [message] - Commits the changes in the staging area to the repository with a message
git status - Shows the status of the repository, including the changes in the staging area and the current branch
git log - Shows the commit history of the repository
git show [commit] - Shows details about a specific commit
git diff - Shows the differences between the staging area and the most recent commit
git branch - Lists all the branches in the repository
git branch [branch-name] - Creates a new branch with the specified name
git checkout [branch-name] - Switches to the specified branch
git checkout -b [branch-name] - Creates a new branch and switches to it in one command
git merge [branch-name] - Merges the specified branch into the current branch
git stash - Temporarily saves changes that have not been committed
git stash pop - Restores the most recently stashed changes
git stash list - Shows a list of all stashes
git stash apply [stash] - Applies a specific stash
git reset [file] - Unstages a file
git checkout [file] - Discards changes to a file
git fetch - Downloads objects and refs from a remote repository
git pull - Fetches changes from a remote repository and merges them into the current branch
git push [remote] [branch] - Pushes a branch to a remote repository
git remote - Shows a list of remote repositories
git remote add [remote] [url] - Adds a new remote repository
git remote show [remote] - Shows details about a specific remote repository
git remote rename [old-name] [new-name] - Renames a remote repository
git remote remove [remote] - Removes a remote repository
git tag - Shows a list of tags in the repository
git tag [tag-name] - Creates a new tag
git tag -a [tag-name] -m [message] - Creates an annotated tag with a message
git tag -d [tag-name] - Deletes a tag
git show [tag] - Shows details about a specific tag
git push [remote] [tag] - Pushes a tag to a remote repository
git push [remote] --tags - Pushes all tags to a remote repository
git config - Shows the configuration settings for the repository
git config --global [setting] [value] - Sets a global configuration setting

Top comments (0)