All git commands list?
Here’s a comprehensive list of commonly used Git commands along with a brief description of each. This is not an exhaustive list, but it covers most of the commands you’ll encounter in everyday Git usage.
Basic Commands
git init
: Initializes a new Git repository.git clone <repository>
: Clones a repository into a new directory.git add <file>
: Stages changes in the specified file for the next commit.git add .
: Stages all changes in the current directory.git commit -m "<message>"
: Commits the staged changes with a message.git status
: Shows the status of changes as untracked, modified, or staged.git log
: Displays the commit history.git diff
: Shows the changes between commits, commit and working tree, etc.git reset <file>
: Unstages a file while retaining the changes in the working directory.git checkout <commit>
: Checks out a specific commit.git checkout <branch>
: Switches to the specified branch.git branch
: Lists all branches in the repository.git branch <branch-name>
: Creates a new branch.git merge <branch>
: Merges the specified branch into the current branch.git pull
: Fetches from the remote repository and merges.git push
: Pushes local changes to the remote repository.
Remote Commands
git remote -v
: Lists all configured remote repositories.git remote add <name> <url>
: Adds a new remote repository.git remote remove <name>
: Removes a remote repository.git fetch <remote>
: Fetches changes from the remote repository without merging.git push <remote> <branch>
: Pushes changes to a specific remote branch.
Branching and Merging
git checkout -b <branch-name>
: Creates a new branch and switches to it.git branch -d <branch-name>
: Deletes a branch.git branch -D <branch-name>
: Force deletes a branch.git merge --no-ff <branch>
: Merges a branch without fast-forwarding.git rebase <branch>
: Applies commits from the current branch on top of another branch.
Stashing
git stash
: Stashes changes in the working directory.git stash apply
: Applies the most recent stash.git stash list
: Lists all stashed changes.git stash drop
: Deletes the most recent stash.git stash pop
: Applies and removes the most recent stash.
Tagging
git tag
: Lists all tags.git tag <tag-name>
: Creates a new tag.git tag -a <tag-name> -m "<message>"
: Creates an annotated tag.git push origin <tag-name>
: Pushes a specific tag to the remote repository.
Configuration
git config --global user.name "<name>"
: Sets the global username.git config --global user.email "<email>"
: Sets the global email.git config --list
: Lists all configuration settings.
Miscellaneous
git show <commit>
: Displays information about a specific commit.git reset --hard
: Resets the working directory and index to the last commit (WARNING: this will lose uncommitted changes).git cherry-pick <commit>
: Applies the changes from a specific commit to the current branch.git revert <commit>
: Creates a new commit that undoes the changes made in a specific commit.git bisect
: A tool to find the commit that introduced a bug by binary search.git clean -fd
: Removes untracked files and directories (use with caution).
Help
git help <command>
: Displays help information for a specific command.git --version
: Displays the current version of Git installed.
Conclusion
This list covers many of the commands you'll use frequently in Git. As you become more familiar with Git, you may discover additional commands and options that suit your workflow. Always refer to the official Git documentation for more detailed information on each command.
Comments
Post a Comment