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!

Git and GitHub are essential tools for modern developers. 1. Use Git for version control: create branches for parallel development, merge branches, and roll back errors. 2. Use GitHub for team collaboration: code review through PullRequest to resolve merge conflicts. 3. Practical tips and best practices: submit regularly, submit messages clearly, use .gitignore, and back up the code base regularly.

Git and GitHub are not the same thing: Git is a distributed version control system, and GitHub is an online platform based on Git. Git helps developers manage code versions and achieve collaboration through branching, merge and other functions; GitHub provides code hosting, review, problem management and social interaction functions, enhancing Git's collaboration capabilities.

After installing Git, in order to use more efficiently, the following settings are required: Set user information (name and mailbox) Select text editor Set external merge tool Generate SSH key settings Ignore file mode

Resolve: When Git download speed is slow, you can take the following steps: Check the network connection and try to switch the connection method. Optimize Git configuration: Increase the POST buffer size (git config --global http.postBuffer 524288000), and reduce the low-speed limit (git config --global http.lowSpeedLimit 1000). Use a Git proxy (such as git-proxy or git-lfs-proxy). Try using a different Git client (such as Sourcetree or Github Desktop). Check for fire protection

Causes of slow Git downloads include poor network connections, Git server problems, large files or large submissions, Git configuration issues, insufficient computer resources, and other factors such as malware. Workarounds include improving network connectivity, adjusting firewall settings, avoiding downloading unnecessary files or submissions, optimizing Git configuration, providing adequate computer resources, and scanning and removing malware.

How to update local Git code? Use git fetch to pull the latest changes from the remote repository. Merge remote changes to the local branch using git merge origin/<remote branch name>. Resolve conflicts arising from mergers. Use git commit -m "Merge branch <Remote branch name>" to submit merge changes and apply updates.

Steps to update git code: Check out code: git clone https://github.com/username/repo.git Get the latest changes: git fetch merge changes: git merge origin/master push changes (optional): git push origin master

You can delete a Git branch through the following steps: 1. Delete the local branch: Use the git branch -d <branch-name> command; 2. Delete the remote branch: Use the git push <remote-name> --delete <branch-name> command; 3. Protected branch: Use git config branch. <branch-name>.protected true to add the protection branch settings.


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

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

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