Introducing the list of commonly used Git commands
1. Quick check of common Git commands
git branch View all local branches
git status View the current status
git commit Submit
git branch -a View all branches
git branch -r View all remote branches
git commit -am "init" Submit and add comments
git remote add origin git@192.168.1.119:ndshow
git push origin master Push the file to the server
git remote show origin Display the resources in the remote library origin
git push origin master:develop
git push origin master:hb-dev Compare the local library to the server Library association
git checkout --track origin/dev Switch to the remote dev branch
git branch -D master develop Delete the local library develop
git checkout -b dev Create a new local branch dev
git merge origin/dev Merge branch dev with the current branch
git checkout dev Switch to the local dev branch
git remote show View the remote library
git add .
git rm file name (including path) Delete the specified file from git
git clone git://github.com/schacon/grit.git Pull the code from the server
git config --list View all users
git ls-files View what has been submitted
git rm [file name] Delete a file
git commit -a Commit all changes to the current repos
git add [file name] Add a file to git index
git commit -v When you use the -v parameter, you can see the difference in commits
git commit -m "This is the message describing the commit" Add commit information
git commit -a -a represents add, adding all Add the change to the git index and then commit
git commit -a -v General commit command
git log Look at your commit log
git diff Check the updates that have not been staged
git rm a.a move Remove files (delete from the staging area and workspace)
git rm --cached a.a Remove files (only delete from the staging area)
git commit -m "remove" Remove files (from Git Delete)
git rm -f a.a forcefully remove the modified file (delete from the staging area and workspace)
git diff --cached or $ git diff --staged to view uncommitted updates
git stash push Push the file to a temporary space
git stash pop Pop the file from the temporary space
--------------------- ------------------------------------
git remote add origin git@github.com:username /Hello-World.git
git push origin master Submit the local project to the server
-------------------------- ----------------------------------
git pull local and server synchronization
---- -------------------------------------------------- -----------
git push (remote warehouse name) (branch name) Push the local branch to the server.
git push origin serverfix:awesomebranch
----------------------------------------- ----------------------------
git fetch is equivalent to getting the latest version from the remote to the local, and will not automatically merge
git commit -a -m "log_message" (-a is to submit all changes, -m is to add log information) Local changes are synchronized to the server:
git branch branch_0.1 master creates branch_0.1 branch from the main branch master
git branch -m branch_0.1 branch_1.0 Rename branch_0.1 to branch_1.0
git checkout branch_1.0/master Switch to branch_1.0/master branch
du -hs
git branch delete remote branch
git push origin :branch_remote_name
git branch -r -d branch_remote_name
---------------------- -------------------------------------
Initialize the version library and submit it to Remote server side
mkdir WebApp
cd WebApp
git init local initialization
touch README
git add README add file
git commit -m 'first commit'
git remote add origin git@github.com:daixu/WebApp.git
Add a remote server
The above command will add a remote server library with the URL address 'git@github.com:daixu/WebApp.git' and the name origin. When submitting code in the future, you only need to use the origin alias
Recommendation (free): Git
2. Git command cheat sheet
1. Commonly used Git commands
Command |
Brief description |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
##git add |
Add to the staging area |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git add–interactive |
Interactive add |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
##git apply
| ##Apply patch|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
##Apply email format patch |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git annotate |
## Synonyms, equivalent to git blame |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git archive |
##File archive packaging
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git bisect
| ##Binary search|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git cherry-pick |
##Submit pick |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git citool |
##Graphical submission, equivalent to git gui Command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git clean
| ##Clear untracked files in the workspace|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
##Clone repository |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
##submit |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Query and modify configuration |
| git describe||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Visually display commit IDs by milestone | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git diff |
##Difference comparison |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git difftool |
Calling the graphical difference comparison tool |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git fetch |
Get the commit of the remote repository |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git format-patch |
Create a patch file in email format. See git am Command |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
##git grep
|
file content Search positioning tool
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git gui
|
Based on Tcl/ Tk 's graphical tool, focusing on operations such as submission |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git help
| ##help|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git init |
##Repository initialization |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git init-db* |
## Synonyms, equivalent to git init
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git log
| ##Display commit log
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git push |
##Push to the remote repository |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git rebase |
##branch rebase
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git rebase–interactive
| ##Interactive branch rebase
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
## Branch and other reference change record management |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Remote repository management |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Synonyms, equivalent to git config |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Reset changed branch " | cursor" points to |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git rev-parse |
Convert various reference representations to hashes Value etc |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git revert |
Reverse commit |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
##git rm |
Delete file |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git show |
##Display various types of objects
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git stage*
| ## Synonyms, equivalent to git add|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git tag |
##Milestone Management |
Commands |
A brief description |
git commit-tree |
Creates a commit from a tree object |
# #git hash-object |
Compute hash value or create object from standard input or file |
git ls-files |
Display workspace and staging area files |
git ls-tree |
Display the files contained in the tree object |
git mktag |
Read standard input to create a milestone object |
git mktree |
Read standard input to create a tree object |
git read-tree |
Read the tree object to the temporary storage area |
git update-index |
Register the workspace content to the staging area and manage the staging area |
git unpack-file |
Creates a temporary file containing the contents of the specified blob |
git write-tree |
Create a tree object from the staging area |
3. Reference operation related commands
Command |
Brief description |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
##git check-ref-format |
Check whether the reference name conforms to the specification |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
##git for-each-ref
|
Reference iterator, for shell Programming | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git ls-remote
|
Display references to remote repositories
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git name-rev
|
Display commit ID as friendly name |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
git peek-remote*
|
Outdated commands, please use git ls-remote |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
##git rev-list |
Show version range |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
##git show-branch
|
Display branch list and topological relationship
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Display or set symbol references |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Update reference point |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Verify GPG Signed Tag |
4. Commands related to repository management
7. Protocol related commands
8. Commands related to repository conversion and interaction
|
The above is the detailed content of Introducing the list of commonly used Git commands. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Git is a version control system, and GitHub is a Git-based code hosting platform. Git is used to manage code versions and supports local operations; GitHub provides online collaboration tools such as Issue tracking and PullRequest.

Git and GitHub are not the same thing. Git is a version control system, and GitHub is a Git-based code hosting platform. Git is used to manage code versions, and GitHub provides an online collaboration environment.

GitHub is not difficult to learn. 1) Master the basic knowledge: GitHub is a Git-based version control system that helps track code changes and collaborative development. 2) Understand core functions: Version control records each submission, supporting local work and remote synchronization. 3) Learn how to use: from creating a repository to push commits, to using branches and pull requests. 4) Solve common problems: such as merge conflicts and forgetting to add files. 5) Optimization practice: Use meaningful submission messages, clean up branches, and manage tasks using the project board. Through practice and community communication, GitHub’s learning curve is not steep.

On your resume, you should choose to write Git or GitHub based on your position requirements and personal experience. 1. If the position requires Git skills, highlight Git. 2. If the position values community participation, show GitHub. 3. Make sure to describe the usage experience and project cases in detail and end with a complete sentence.

Microsoft does not own Git, but owns GitHub. 1.Git is a distributed version control system created by Linus Torvaz in 2005. 2. GitHub is an online code hosting platform based on Git. It was founded in 2008 and acquired by Microsoft in 2018.

Starting from Git is more suitable for a deep understanding of version control principles, and starting from GitHub is more suitable for focusing on collaboration and code hosting. 1.Git is a distributed version control system that helps manage code version history. 2. GitHub is an online platform based on Git, providing code hosting and collaboration capabilities.

The reason for using GitHub to manage HTML projects is that it provides a platform for version control, collaborative development and presentation of works. The specific steps include: 1. Create and initialize the Git repository, 2. Add and submit HTML files, 3. Push to GitHub, 4. Use GitHubPages to deploy web pages, 5. Use GitHubActions to automate building and deployment. In addition, GitHub also supports code review, Issue and PullRequest features to help optimize and collaborate on HTML projects.

Git is an open source distributed version control system that helps developers track file changes, work together and manage code versions. Its core functions include: 1) record code modifications, 2) fallback to previous versions, 3) collaborative development, and 4) create and manage branches for parallel development.
