1 git init # initialize the local git repository (create a new warehouse)2git config--global user.name"XXX "# Configure user name3git config--global user.email"[email protected] "# Configure mail4git config--global color.uitrue# git status and other commands auto-coloring5git config--Global Color.status Auto6git config--Global Color.diff Auto7git config--Global Color.branch Auto8git config--Global color.interactive Auto9git clone Git+ssh://[email protected]192.168.53.168/vt.git # clone remote repositoryTen git status # View current version status (modified) One git add xyz # Add xyz file to index A git Add. # Add all the changed files to index in the current sub-directory -Git commit-m'XXX'# Submit -git commit--amend-m'XXX'# Merge Last commit (for repeated modifications) theGit commit-am'XXX'# Combine add and commit into one step - git rm xxx # delete files in index -Git rm-r *# Recursive Delete - git log # Displays the commit log +Git log-1# 1 rows of logs are displayed-n is n rows -Git log-5 +Git log--Stat # Displays the commit log and related change files AGit log-p-m at git show dfb02e6e4f2f7b573337763e5c0013802e392818 # shows the details of a commit - git show dfb02 # can only use the first few Commitid - git show Head # show head commit log -Git show head^ # show the parent of HEAD (previous version) the commit log ^^ to two versions ^5 for the last 5 versions - git tag # shows the existing tag -Git tag-a v2.0-M'XXX'# Add v2.0 tag inGit show v2.0# Show v2.0 log and details -Git log v2.0# Show Log of v2.0 to git diff # shows all changes not added to index +Git diff--Cached # Shows all changes that have been added to the index but have not yet been commit -git diff head^# Compare the differences with previous versions thegit diff HEAD--./lib # diff vs. head version lib directory *git diff origin/Master.. Master # Compare Remote Branch master with local branch not on master $Git diff origin/master. Master--Stat # displays only the diff files and does not show the specific contentPanax NotoginsengGit remote add origin git+ssh://[email protected]192.168.53.168/vt.git # Add remote definition (for push/pull/fetch) - git Branch # show local branch theGit branch--contains50089# shows the branch that contains commit 50089 +Git branch-A # Show all branches AGit branch-R # Show all original branches theGit branch--merged # shows all branches that have been merged into the current branch +Git branch--no-merged # shows all branches that are not merged into the current branch -Git branch-m Master master_copy # Local branch renamed $Git checkout-B master_copy # Creates a new branch from the current branch master_copy and checks out $Git checkout-B Master Master_copy # The full version above -git checkout features/performance # Check out existing features/Performance Branch -git checkout--track hotfixes/bjvep933 # Check out remote branch hotfixes/BJVEP933 and create a local trace branch theGit checkout v2.0# Check out version v2.0 -git checkout-b devel origin/Develop # Create a new local branch from a remote branch develop devel and check outWuyiGit checkout--Readme # Check out the head version of the Readme file (can be used to modify the error fallback) thegit merge origin/Master # Merge Remote Master branch to current branch -Git cherry-Pick ff44785404a8e # Changes to merge commit ff44785404a8e Wu git push Origin master # push the current branch to the remote master branch -git push origin:hotfixes/bjvep933 # remove hotfixes/from remote repositoriesBJVEP933 Branch Aboutgit push--Tags # push all tags to the remote repository $ git fetch # get all remote branches (do not update local branch and merge required) -git fetch--Prune # Get all the original branches and clear the deleted branches on the server - Git pull Origin master # get remote Branch Master and merge to current branch - git mv Readme README2 # Rename file Readme to README2 AGit Reset--Hard HEAD # Resets the current version to HEAD (typically used for merge failure fallback) + git rebase thegit branch-d hotfixes/bjvep933 # Delete Branch hotfixes/BJVEP933 (This branch modification has been merged into another branch) -git branch-d hotfixes/bjvep933 # force Delete branch hotfixes/BJVEP933 $Git ls-Files # Lists the file that Git index contains theGit show-Branch # Diagram of current branch history theGit show-branch--All # Diagram of all branch history the git whatchanged # show file changes for commit history the git revert dfb02e6e4f2f7b573337763e5c0013802e392818 # Undo Commit dfb02e6e4f2f7b573337763e5c0013802e392818 -Git ls-Tree HEAD # internal command: Show a Git object inGit rev-parse v2.0# Internal command: Displays a ref for the SHA1 HASH the git Reflog # shows all commits, including orphaned nodes thegit show [email protected]{5} About git show [email protected]{yesterday} # shows the status of the Master branch yesterday thegit log--pretty=format:'%h%s'--Graph # Diagram commit log theGit show head~3 theGit show-s--pretty=Raw 2be7fcb476 + git Stash # Staging current changes, all to the head state - git stash List # view all staging thegit stash show-p [email protected]{0} # Refer to the first time stagingBayigit stash apply [email protected]{0} # Apply first time staging thegit grep"Delete from "# File search text" delete from " theGit grep-e'#define'-- and-e sort_dirent - git GC -Git fsck
git commands to collect and organize