In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what Git commands are commonly used, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
I. Quick check of common Git commands
Git branch view all local branches
Git status to view current status
Git commit submission
Git branch-a view all branches
Git branch-r View all remote branches
Git commit-am "init" submit and comment
Git remote add origin git@192.168.1.119:ndshow
Git push origin master pushes files to the server
Git remote show origin displays the resources in the remote library origin
Git push origin master:develop
Git push origin master:hb-dev associates local libraries with libraries on the server
Git checkout-- track origin/dev switches to remote dev branch
Git branch-D master develop deletes the local library develop
Git checkout-b dev establishes a new local branch dev
Git merge origin/dev merges the branch dev with the current branch
Git checkout dev switches to local dev branch
Git remote show View remote Library
Git add.
Git rm file name (including path) removes the specified file from git
Git clone git://github.com/schacon/grit.git pulled the code from the server
Git config-- list looks at all users
Git ls-files, look at what has been submitted
Git rm [file name] Delete a file
Git commit-a submits all changes to the current repos
Git add [file name] add a file to git index
Git commit-v you can see the difference in commit when you use the-v parameter
Git commit-m "This is the message describing the commit" add commit information
Git commit-a-a stands for add, adding all the change to git index and then commit
Git commit-a-v general submit command
Git log, look at your commit's log.
Git diff to view updates that have not been temporarily saved
Git rm a.a removes files (removes from staging and workspaces)
Git rm-cached a.a removes files (only deleted from the staging area)
Git commit-m "remove" removes files (deleted from Git)
Git rm-f a.a forcibly remove modified files (deleted from staging and workspace)
Git diff-- cached or $git diff-- staged to view updates that have not been submitted
Git stash push gives the file to push 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 submits the local project to the server
Git pull synchronizes locally with the server
-
Git push (remote repository name) (branch name) pushes the local branch to the server.
Git push origin serverfix:awesomebranch
-
Git fetch is equivalent to getting the latest version from remote to local, and will not automatically merge
Git commit-a-m "log_message" (- a commits all changes,-m adds log information) local modifications are synchronized to the server:
Git branch branch_0.1 master creates a branch_0.1 branch from the main branch master
Git branch-m branch_0.1 branch_1.0 renamed branch_0.1 to branch_1.0
Git checkout branch_1.0/master switches to branch_1.0/master branch
Du-hs
Git branch removes a remote branch
Git push origin: branch_remote_name
Git branch-r-d branch_remote_name
Initialize the version library and submit it to the remote server
Mkdir WebApp
Cd WebApp
Git init local initialization
Touch README
Git add README add Files
Git commit-m 'first commit'
Git remote add origin git@github.com:daixu/WebApp.git
Add a remote server
The above command adds a remote server library whose URL address is' git@github.com:daixu/WebApp.git', name is origin, and you only need to use the origin alias when submitting the code later
Recommended (free): Git
2. Git command quick look-up table
1. Commonly used Git commands
Command
Brief description
Git add
Add to staging area
Git add-interactive
Interactive add
Git apply
Apply patches
Git am
Apply email format patches
Git annotate
Synonym, equivalent to git blame
Git archive
File archiving and packing
Git bisect
Binary search
Git blame
The file is traced line by line.
Git branch
Branch management
Git cat-file
Version library object research tool
Git checkout
Check out to the workspace, switch, or create a branch
Git cherry-pick
Submit selection
Git citool
Graphical submission, equivalent to git gui command
Git clean
Clear workspace untracked files
Git clone
Clone version library
Git commit
Submit
Git config
Query and modify configuration
Git describe
Visually display the submission ID through milestones
Git diff
Difference comparison
Git difftool
Call the graphical difference comparison tool
Git fetch
Get the submission of the remote version library
Git format-patch
Create a patch file in mail format. See git am command
Git grep
File content search and location tool
Git gui
Graphical tools based on Tcl/Tk, focusing on operations such as submission
Git help
Help
Git init
Version library initialization
Git init-db*
Synonym, equivalent to git init
Git log
Show submission Log
Git merge
Branch merging
Git mergetool
Graphical conflict resolution
Git mv
Rename
Git pull
Pull back the submission of the remote version library
Git push
Push to remote version library
Git rebase
Branch transformation
Git rebase-interactive
Interactive branch change base
Git reflog
Branch and other reference change record management
Git remote
Remote version library management
Git repo-config*
Synonym, equivalent to git config
Git reset
Reset to change the branch "cursor" point
Git rev-parse
Convert various reference representations to hash values, etc.
Git revert
Reverse submission
Git rm
Delete a file
Git show
Display various types of objects
Git stage*
Synonym, equivalent to git add
Git stash
Save and restore progress
Git status
Show workspace file status
Git tag
Milestone management
2. Commands related to object library operation
Command
Brief description
Git commit-tree
Create a submission from a tree object
Git hash-object
Calculate hashes or create objects from standard input or files
Git ls-files
Show 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 staging area
Git update-index
Register the content of the workspace to the temporary storage area and manage the temporary storage area
Git unpack-file
Create a temporary file that contains 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
Show references to the remote version library
Git name-rev
Display the submission ID as a friendly name
Git peek-remote*
Outdated commands, please use git ls-remote
Git rev-list
Show version range
Git show-branch
Display a list of branches and topological relationships
Git show-ref
Show local references
Git symbolic-ref
Display or set symbol references
Git update-ref
Update the direction of the reference
Git verify-tag
Verify the Tag of GPG signature
4. Commands related to version library management
Command
Brief description
Git count-objects
Displays the number of loose objects and disk occupancy
Git filter-branch
Version library reconstruction
Git fsck
Object library integrity check
Git fsck-objects*
Synonym, equivalent to git fsck
Git gc
Version library storage optimization
Git index-pack
Create a corresponding index file from the packaged file
Git lost-found*
Obsolete, use the git fsck-lost-found command
Git pack-objects
Read the object ID from standard input and package it to a file
Git pack-redundant
Find redundant pack files
Git pack-refs
Package references into A. git/packed-refs file
Git prune
Delete expired objects from the object library
Git prune-packed
Delete loose objects that have been packaged
Git relink
Establish a hard connection for the same objects in the local version library
Git repack
Package loose objects that are not packaged in the version library
Git show-index
Read the index file of the package and display the contents of the package file
Git unpack-objects
Release files from packaged files
Git verify-pack
Check the object library package file
5. Commands related to data transmission
Command
Brief description
Git fetch-pack
Execute this command locally when you execute a git fetch or git pull command to get missing objects from other version libraries
Git receive-pack
A command executed remotely when a git push command is executed to receive pushed data
Git send-pack
A command executed locally when the git push command is executed to push data to other versions of the library
Git upload-archive
When you execute the git archive-remote command to create an archive based on the remote version library, the remote version library executes this command to transfer the archive
Git upload-pack
Execute this command remotely when you execute a git fetch or git pull command to package and upload objects
6. Mail-related commands
Command
Brief description
Git imap-send
Send patches via IMAP
Git mailinfo
Export submission instructions and patches from email
Git mailsplit
Extract messages from mailboxes in mbox or Maildir format into files one by one
Git request-pull
Create information containing the differences between submissions and the address where the PULL operation is performed
Git send-email
Send an email
7. Protocol-related commands
Command
Brief description
Git daemon
Implement the Git protocol
Git http-backend
CGI program that implements HTTP protocol and supports intelligent HTTP protocol
Git instaweb
Instantly launch the browser to browse the current version library through gitweb
Git shell
Restricted shell, which provides SSH access to execute Git commands only
Git update-server-info
Update the auxiliary files required by the dumb protocol
Git http-fetch
Obtain the version library through HTTP protocol
Git http-push
Push via HTTP/DAV protocol
Git remote-ext
Called by the Git command to provide extended protocol support through external commands
Git remote-fd
Called by the Git command, using the file descriptor as the protocol interface
Git remote-ftp
Called by the Git command to provide support for the FTP protocol
Git remote-ftps
Called by the Git command to provide support for the FTPS protocol
Git remote-http
Called by the Git command to provide support for the HTTP protocol
Git remote-https
Called by the Git command to provide support for the HTTPS protocol
Git remote-testgit
Protocol extension sample script
8. Commands related to version library conversion and interaction
Command
Brief description
Git archimport
Import the Arch version library to Git
Git bundle
Submit packaging and unpacking for delivery between different versions of libraries
Git cvsexportcommit
Check out a submission of Git as a CVS
Git cvsimport
Import the CVS version library into Git. Or use cvs2git
Git cvsserver
Git's CVS protocol simulator, which provides CVS commands with access to Git version libraries
Git fast-export
Export submission to git-fast-import format
Git fast-import
Common tools for migrating other version libraries to Git
Git svn
Git as the front-end operation Subversion
9. Merge related auxiliary commands
Command
Brief description
Git merge-base
For other scripts to call to find two or more submitted closest common ancestors
Git merge-file
Perform a three-way file merge for two different versions of the file
Git merge-index
Invokes the specified conflict resolution tool on a conflict file in index
Git merge-octopus
Merge more than two branches. See git merge's octopus merge strategy
Git merge-one-file
Standard helper program called by git merge-index
Git merge-ours
Merge to use the local version and discard others' version. See git merge's ours merge strategy
Git merge-recursive
A three-way merge of two branches. See git merge's recursive merge strategy
Git merge-resolve
A three-way merge of two branches. See git merge's resolve merge strategy
Git merge-subtree
Subtrees merge. See git merge's subtree merge strategy
Git merge-tree
Explicit three-way merge results without changing the temporary storage area
Git fmt-merge-msg
A script call for performing a merge operation to create a merge submission description
Git rerere
Reuse recorded conflict resolution
10. Miscellaneous
Command
Brief description
Git bisect-helper
Called by the git bisect command to confirm the progress of the binary search
Git check-attr
Displays whether a file has a property set
Git checkout-index
Copy files from the staging area to the workspace
Git cherry
Find submissions that are not merged to the upstream
Git diff-files
Compare the staging area with the workspace, equivalent to git diff-raw
Git diff-index
Compare temporary storage area with version library, which is equivalent to git diff-cached-raw
Git diff-tree
Compare two tree objects, equivalent to git diff-raw A B
Git difftool-helper
Called by the git difftool command, the difference comparison tool to be used by default
Git get-tar-commit-id
Extract the submission ID from the tar package created by git archive
Git gui-askpass
Get user password input interface of command git gui
Git notes
Submit comment management
Git patch-id
Patch unique ID is generated after the patch filters line numbers and white space characters
Git quiltimport
Apply the Quilt patch list to the current branch
Git replace
Submit replacement
Git shortlog
Summary output of git log, suitable for product release notes
Git stripspace
Delete blank lines for other scripts to call
Git submodule
Submodule management
Git tar-tree
Outdated commands, please use git archive
Git var
Show Git environment variables
Git web-browse
Start a browser to view directories or files
Git whatchanged
Displays the submission history and the changes submitted each time
Git-mergetool-lib
Included in other scripts to provide the selection and execution of merge / difference comparison tools
Git-parse-remote
Included in other scripts to provide functions to manipulate the remote version library
Git-sh-setup
Included in other scripts to provide libraries for shell programming
The following script House editor specially shares a picture version for you.
Git commonly used commands quick look-up table. Click to view the larger picture.
Git Command reference Manual (text version)
Git init # initialize the local git repository (create a new warehouse)
Git config-global user.name "xxx" # configure user name
Git config-global user.email "xxx@xxx.com" # configure email
Git config-- commands such as global color.ui true # git status automatically color
Git config-global color.status auto
Git config-global color.diff auto
Git config-global color.branch auto
Git config-global color.interactive auto
Git clone git+ssh://git@192.168.53.168/VT.git # clone remote Warehouse
Git status # View current version status (whether to modify or not)
Git add xyz # add xyz file to index
Git add. # add all changed files in the current subdirectory to index
Git commit-m 'xxx' # submission
Git commit-- amend-m 'xxx' # merges the last submission (for repeated modifications)
Git commit-am 'xxx' # combines add and commit into one step
Git rm xxx # Delete files in index
Git rm-r * # Recursive deletion
Git log # displays the submission log
Git log-1 # shows 1 line of log-n is n line
Git log-5
Git log-stat # shows the submission log and related changes
Git log-p-m
Git show dfb02e6e4f2f7b573337763e5c0013802e392818 # displays the details of a submission
Git show dfb02 # can only use the first few digits of commitid
Git show HEAD # displays the HEAD submission log
Git show head ^ # shows that the commit log ^ ^ of the parent of HEAD (previous version) is the previous two versions ^ 5 and the previous five versions
Git tag # shows tag that already exists
Git tag-a v2.0-m 'xxx' # add v2.0 tag
Git show v2.0 # displays the log and details of v2.0
Git log v2.0 # displays logs for v2.0
Git diff # shows all changes that have not been added to index
Git diff-- cached # shows all changes that have been added to index but not yet commit
Git diff head ^ # compares the differences with the previous version
Git diff HEAD -. / lib # compares the differences with the lib directory of the HEAD version
Git diff origin/master..master # compare that the remote branch master has a local branch master that does not exist
Git diff origin/master..master-- stat # shows only files with differences, not specific content
Git remote add origin git+ssh://git@192.168.53.168/VT.git # adds remote definition (for push/pull/fetch)
Git branch # shows local branches
Git branch-- contains 50089 # displays branches containing submission 50089
Git branch-a # shows all branches
Git branch-r # shows all original branches
Git 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 master_copy from the current branch and checks out
The full version of git checkout-b master master_copy #
Git checkout features/performance # check out an existing features/performance branch
Git checkout-- track hotfixes/BJVEP933 # checks out the remote branch hotfixes/BJVEP933 and creates a local tracking branch
Git checkout v2.0 # check out version v2.0
Git checkout-b devel origin/develop # creates a new local branch devel from the remote branch develop and checks out
Git checkout-README # checks out the head version of the README file (can be used to correct error fallback)
Git merge origin/master # merges a remote master branch to the current branch
Git cherry-pick ff44785404a8e # merge and submit changes to ff44785404a8e
Git push origin master # push the current branch to the remote master branch
Git push origin: hotfixes/BJVEP933 # Delete the hotfixes/BJVEP933 branch of the remote warehouse
Git push-tags # pushes all tag to the remote warehouse
Git fetch # get all remote branches (local branches are not updated, merge is required)
Git fetch-- prune # gets all original branches and clears deleted branches on the server
Git pull origin master # get the remote branch master and merge to the current branch
Git mv README README2 # rename the file README to README2
Git reset-- hard HEAD # resets the current version to HEAD (usually used for merge failure fallback)
Git rebase
Git branch-d hotfixes/BJVEP933 # Delete branch hotfixes/BJVEP933 (this branch modification has been merged into other branches)
Git branch-D hotfixes/BJVEP933 # forcibly delete branch hotfixes/BJVEP933
Git ls-files # lists the files contained in git index
Git show-branch # illustrates the current branch history
Git show-branch-- all # illustrates the history of all branches
Git whatchanged # shows the file modifications corresponding to the submission history
Git revert dfb02e6e4f2f7b573337763e5c0013802e392818 # undo submission dfb02e6e4f2f7b573337763e5c0013802e392818
Git ls-tree HEAD # internal command: display a git object
Git rev-parse v2.0 # internal command: displays the SHA1 HASH for a ref
Git reflog # shows all submissions, including orphaned nodes
Git show HEAD@ {5}
Git show master@ {yesterday} # shows the status of the master branch yesterday
Git log-- pretty=format:'%h% s'--graph # graphic submission log
Git show HEAD~3
Git show-s-pretty=raw 2be7fcb476
Git stash # temporarily stores the current changes and puts all of them to HEAD status
Git stash list # View all staging
Git stash show-p stash@ {0} # reference first staging
Git stash apply stash@ {0} # first temporary storage for application
Search for the text "delete from" in git grep "delete from" # file
Git grep-e' # define'-- and-e SORT_DIRENT
Git gc
Git fsck
Git is a very powerful distributed version control system. It is not only suitable for managing the source code of large open source software, but also has many advantages in managing private documents and source code.
Git common operation commands:
1) remote warehouse related commands
Check out warehouse: $git clone git://github.com/jquery/jquery.git
View the remote warehouse: $git remote-v
Add remote warehouse: $git remote add [name] [url]
Delete remote warehouse: $git remote rm [name]
Modify the remote warehouse: $git remote set-url-- push [name] [newUrl]
Pull remote warehouse: $git pull [remoteName] [localBranchName]
Push remote warehouse: $git push [remoteName] [localBranchName]
* if you want to submit a local branch test to the remote repository as a master branch of the remote repository, or as another branch called test, as follows:
$git push origin test:master / / submit a local test branch as a remote master branch
$git push origin test:test / / submit a local test branch as a remote test branch
2) commands related to branch operation
View the local branch: $git branch
View remote branches: $git branch-r
Create a local branch: $git branch [name]-Note that the new branch will not automatically switch to the current branch after it is created
Switch branches: $git checkout [name]
Create a new branch and immediately switch to the new branch: $git checkout-b [name]
Delete branches: the $git branch-d [name]-d option can only delete branches that have already participated in the merge, and cannot be deleted for branches that have not been merged. If you want to force the deletion of a branch, use the-D option
Merge branch: $git merge [name]-merge the branch named [name] with the current branch
Create a remote branch (local branch push to remote): $git push origin [name]
Delete remote branch: $gitpush origin: heads/ [name] or $gitpush origin: [name]
* create an empty branch: (remember to submit changes to your current branch before executing the command, otherwise you will be forced to delete it without regret)
$git symbolic-ref HEAD refs/heads/ [name]
$rm .git / index
$git clean-fdx
3) tag operation related commands
View version: $git tag
Create version: $git tag [name]
Delete version: $git tag-d [name]
View the remote version: $git tag-r
Create a remote version (local version push to remote): $git push origin [name]
Delete the remote version: $git push origin: refs/tags/ [name]
Merge the tag of the remote warehouse into the local: $git pull origin-- tags
Upload local tag to remote repository: $git push origin-- tags
Create an annotated tag:$ git tag-a [name]-m 'yourMessage'
4) Operation commands related to sub-module (submodule)
Add submodules: $git submodule add [url] [path]
For example, $git submodule add git://github.com/soberh/ui-libs.git src/main/webapp/ui-libs
Initialization submodule: $git submodule init-run only once when the warehouse is checked out for the first time
Update sub-module: $git submodule update-each time you update or switch branches, you need to run it.
Delete sub-module: (4 steps)
1) $git rm-- cached [path]
2) Edit the ".gitmodules" file to delete the relevant configuration nodes of the sub-module
3) Edit the ".git / config" file to delete the relevant configuration nodes of the sub-module
4) manually delete the remaining directories of the sub-module
5) ignore some files and folders and do not submit
Create a file named ".gitignore" under the repository root, and write unwanted folder names or files, each element on a single line, as shown in
Target
Bin
* .db
=
Git common commands
Git branch view all local branches
Git status to view current status
Git commit submission
Git branch-a view all branches
Git branch-r view all local branches
Git commit-am "init" submit and comment
Git remote add origin git@192.168.1.119:ndshow
Git push origin master pushes files to the server
Git remote show origin displays the resources in the remote library origin
Git push origin master:develop
Git push origin master:hb-dev associates local libraries with libraries on the server
Git checkout-- track origin/dev switches to remote dev branch
Git branch-D master develop deletes the local library develop
Git checkout-b dev establishes a new local branch dev
Git merge origin/dev merges the branch dev with the current branch
Git checkout dev switches to local dev branch
Git remote show View remote Library
Git add.
Git rm file name (including path) removes the specified file from git
Git clone git://github.com/schacon/grit.git pulled the code from the server
Git config-- list looks at all users
Git ls-files, look at what has been submitted
Git rm [file name] Delete a file
Git commit-a submits all changes to the current repos
Git add [file name] add a file to git index
Git commit-v you can see the difference in commit when you use the-v parameter
Git commit-m "This is the message describing the commit" add commit information
Git commit-a-a stands for add, adding all the change to git index and then commit
Git commit-a-v general submit command
Git log, look at your commit's log.
Git diff to view updates that have not been temporarily saved
Git rm a.a removes files (removes from staging and workspaces)
Git rm-cached a.a removes files (only deleted from the staging area)
Git commit-m "remove" removes files (deleted from Git)
Git rm-f a.a forcibly remove modified files (deleted from staging and workspace)
Git diff-- cached or $git diff-- staged to view updates that have not been submitted
Git stash push gives the file to push 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 submits the local project to the server
Git pull synchronizes locally with the server
-
Git push (remote repository name) (branch name) pushes the local branch to the server.
Git push origin serverfix:awesomebranch
-
Git fetch is equivalent to getting the latest version from remote to local, and will not automatically merge
Git commit-a-m "log_message" (- a commits all changes,-m adds log information) local modifications are synchronized to the server:
Git branch branch_0.1 master creates a branch_0.1 branch from the main branch master
Git branch-m branch_0.1 branch_1.0 renamed branch_0.1 to branch_1.0
Git checkout branch_1.0/master switches to branch_1.0/master branch
Du-hs
Mkdir WebApp
Cd WebApp
Git init
Touch README
Git add README
Git commit-m 'first commit'
Git remote add origin git@github.com:daixu/WebApp.git
Git push-u origin master
These are all the contents of this article entitled "what are the Common commands in Git?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.