Git is a distributed version control system, which is easy to operate and set from the rack. This article mainly describes basic operations and terminal operations.
TIPS: git is too busy. Just take this article as a beginner.
Attention
It can be seen from project/. Git/config: (if there are more, you can also learn from it)
- Origin (remote) is the repository version.
- Master (Branch) is the local end and the version being modified
Normally, do not touch origin. If it is triggered, you can use git reset -- hard to reply to the unmodified response.
Git new deployment case
- Git Add. # Save the information to the staging area first, and then add the new information. Therefore, this commit will not be included in it.
- Git add filename
- Git add modify-file # Add. (otherwise, add-a to commit)
- Git add-u # Add only modified records, but not new records.
- Git add-I # In Interactive Mode
Git Division case
Git: Modify shard name and move shards
- Git MV filename New-filename
Git status: Check the current zookeeper
- Git status # view zookeeper of the current deployment case
Git commit
- Git commit
- Git commit-m'commit message'
- Git commit-a-m'commit-message' # commit all modified commit cases, but add the newly added commit case first.
- Git commit-a-V #-V: You can see which contents have been changed in the commit case, and-a will commit all the modified commit cases.
Git produces new branch
- Git branch # list the current number of Branchs
- Git Branch New-branch # generates a new branch (Name: New-branch). If no specific branch is specified, the current branch/master will directly renew it.
- Git Branch New-branch master # new branch (New-branch) generated by the master)
- Git Branch New-branch V1 # A new branch (New-Branch) is generated by TAG (V1)
- Git branch-d New-branch # Remove New-branch
- Git branch-d New-branch # using the new-branch
- Git checkout-B New-branch test # generate a new branch and change it to new-branch at the same time.
- # Related to remote Repository
- Git branch-R # list all repository Branch
- Git branch-A # list all branch
Git checkout switch branch Branch
- Git checkout branch-name # Switch to branch-name
- Git checkout master # Switch slave to master
- Git checkout-B New-branch master # Create a New-branch from the master and switch it over New-branch at the same time
- Git checkout-B newbranch # create a new branch based on the current environment
- Git checkout-B newbranch origin # create a new branch based on the origin
- Git checkout filename # restore the original file to the repository metadata
- Git checkout head. # generate all audit cases (the last version of COMMIT). Note that any modified commit case will be migrated to the previous version. (GIT checkout-F is also supported)
- Git checkout XXXX. # checkout all commit cases (XXXX commit version, XXXX is the first four commit partitions of COMMIT). Note, if any modification is made to the previous version.
- Git checkout -- * # restore the original commit to the previous commit (* change the commit name to restore the previous commit)
Git diff
- Git diff master # what resources are different from the master?
- Git diff -- cached # compared with the original Repository
- Git diff tag1 tag2 # tag1, and diff of tag2
- Git diff tag1: file1 tag2: file2 # tag1, And the diff of file1 and file2 of tag2
- Git diff # compare current location with staging area
- Git diff -- cached # is worse than checking staging area and repository
- Git diff head # is different from the current repository location of the slave
- Git diff New-branch # difference between the current location of git and branch (New-Branch)
- Git diff -- stat
Git tag
- Git tag V1 ebff # log is the content of commit ebff810c461ad1924fc422fd1d01db23d858773b. Set the token to be short and remember the tag: V1.
- Git tag Chinese ebff # tag can also be Chinese, any text can be
- Git tag-D Chinese # Hide tag = Chinese
Git log
- Git log # Show All logs
- Git log -- all # Show All logs (including Branch)
- Git log-P # list all logs and modified records
- Git log-P filename # list the commit log of the current case and the content tolerant parts of the change case
- Git log -- name-only # list which logs have been modified
- Git log -- stat -- Summary # Check the more active cases and row numbers for each version
- Git log filename # All logs in this case
- Git log directory # All logs of this project
- Git log-s 'foo () '# The log contains the string Foo.
- Git log -- no-merges # Do not show merge logs
- Git log -- since = "2 weeks ago" # the last two logs
- Git log -- pretty = oneline # Show LOG method
- Git log -- pretty = short # Show LOG method
- Git log -- pretty = format: '% H was % an, % AR, message: % s'
- Git log -- pretty = format: '% H: % s' -- Graph # There will be simplified text, branches, and so on.
- Git log -- pretty = format: '% H: % s' -- TOPO-order -- Graph # sort by main branch
- Git log -- pretty = format: '% H: % s' -- date-order -- Graph # sort by Time
Git show
- Git show ebff # Check the log Content of commit ebff810c461ad1924fc422fd1d01db23d858773b
- Git show V1 # Check the tag: V1's modified content
- Git show V1: test.txt # Check the test.txt file of Tag: V1 to modify the content
- Git show head # Information modified in this version
- Git show head ^ # Information modified in the previous version
- Git show head ^ # Information modified in the previous version
- Git show head ~ 4 # Information modified before, before, and before
Git Reset Original
- Git reset -- hard head # returns to the beginning
- Git reset -- hard head ~ 3
- Git reset -- soft head ~ 3
- Git reset head filename # Return to unstaging or untracked from staging area without changing the content in the handling case)
Git grep
- Git grep "te" V1 # Check If V1 has "te" strings
- Git grep "te" # Check whether the current version contains "te" strings
Git stash inventory
- Git stash # import to the repository
- Git stash list # list resources in all regions
- Git stash pop # retrieve the latest one and remove it.
- Git stash apply # retrieve the latest stash metadata. However, the stash information is not removed.
- Git stash clear # Clear all stash
Git merge
- Git merge
- Git merge master
- Git merge New-branch
- The GIT version control system of ihower (2) open branch and operate the slave node Repo. x
- In the combination mode set by straight merge, there will be all merged branch commits added to a merge-commit, and there will be two parents between them, and keep all commit logs.
- Squashed commit records into only one merge-commit, and there will be no merged logs. This is true for SVN's merge.
- Cherry-pick only combines the specified commit
- Rebase changes branch points: Find the common ancestor of the two branch to be merged, and then commit it with only the branch to be merged by merge, then use the current branch and then commit. This method does not share the local branch with others, because the re-commit log is cut down.
Command operation
- Git merge <branch_name> # merge another branch. If there is no conflict attack, it will be commit directly. If you need to solve the problem, there will be another commit.
- Git merge -- squash <branch_name> # merge the commit of another branch into a single branch, and specifically combine the fixes bug or new feature of the actual branch, the final result is left. After the merge operation, it will not help you commit it first.
- Git cherry-pick 321d76f # Only combines a specific commit. If you want to merge multiple tables, you can add the-n command to not commit for you first. In this way, you can add multiple pick tables to commit and then git commit.
Git blame
- Git blame filename # all commit statements in this case
Git has been deleted
- Git LS-files-D # view deleted Samples
- Git LS-files-d | xargs git checkout -- # restore the deleted scripts to the original
Git checkout history
- Git GC # The difference between pre-and post-finishing git GC can be seen in: git count-objects.
- Git GC -- prune
- Git fsck -- full
Git revert recovery
- Git revert head # Return to the commit of the previous commit
- Git revert head ^ # back to the previous commit
- Git reset head filename # Return to unstaging or untracked from staging area without changing the content in the handling case)
- Git checkout filename # Return to the initial repository case from unstaging plugin (before modification)
Git rollback is back to the previous version
- Git reset -- soft head ^
- Getting started + git add filename
- Git commit-M 'rollback'
The following is related to the upload repository.
Git remote zookeeper upload client Cases
- Git remote
- Git remote add new-branch http://git.example.com.tw/project.git # Add Branch (origin-> project) for the restore end Repository)
- Git remote show # Show how many repository files exist
- Git remote RM New-branch # abort
- Git remote update # update all repository Branch
- Git branch-R # list all repository Branch
Branch of crawling/cutting Repository
- Git fetch Origin
- Git checkout -- track-B reps-branch origin/reps-branch # capture reps-branch and create this branch on the local reps-branch
Remove the branch of repository
- Git push origin: heads/reps-branch