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 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 know 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
2. Git command quick look-up table
1. Commonly used Git commands
Brief description of the command
Git add added to staging area
Git add-interactive Interactive add
Git apply Application Patch
Git am applies email format patch
A synonym for git annotate, equivalent to git blame
Archiving and packaging of git archive files
Git bisect binary search
Git blame files are retraced line by line
Git branch branch management
Git cat-file version Library object Research tool
Git checkout checks out to the workspace, switches, or creates branches
Git cherry-pick submit selection
Git citool graphical submission, equivalent to git gui command
Git clean clears untracked files in the workspace
Git clone clone version library
Git commit submission
Git config query and modify configuration
Git describe visually displays the submission ID through milestones
Git diff difference comparison
Git difftool calls the graphical difference comparison tool
Git fetch gets the submission of the remote version library
Git format-patch creates a patch file in mail format. See git am command
Git grep document content search and location tool
Git gui is a graphical tool based on Tcl/Tk, focusing on operations such as submission
Git help help
Git init version library initialization
A synonym for git init-db*, equivalent to git init
Git log displays the submission log
Git merge branch merging
Git mergetool graphical conflict resolution
Git mv renaming
Git pull pulls back the submission of the remote version library
Git push pushes to remote version library
Git rebase branch transformation
Interactive branch transformation of git rebase-interactive
Reference change record management such as git reflog branch
Git remote remote version Library Management
A synonym for git repo-config*, equivalent to git config
Git reset reset changes branch "cursor" pointing
Git rev-parse converts various reference representations to hash values, etc.
Git revert reverse submission
Git rm deletes a file
Git show displays various types of objects
A synonym for git stage*, equivalent to git add
Git stash save and restore progress
Git status displays workspace file status
Git tag milestone Management
2. Commands related to object library operation
Brief description of the command
Git commit-tree creates a submission from a tree object
Git hash-object calculates hashes or creates objects from standard input or files
Git ls-files displays workspace and staging area files
Git ls-tree displays the files contained in the tree object
Git mktag reads standard input to create a milestone object
Git mktree reads standard input to create a tree object
Git read-tree reads tree objects to the staging area
Registration of git update-index workspace content to temporary storage area and management of temporary storage area
Git unpack-file creates a temporary file that contains the contents of the specified blob
Git write-tree creates a tree object from the staging area
3. Reference operation related commands
Brief description of the command
Git check-ref-format checks whether the reference name conforms to the specification
Git for-each-ref reference iterator for shell programming
Git ls-remote displays references to the remote version library
Git name-rev displays the submission ID as a friendly name
Git peek-remote* obsolete command, please use git ls-remote
Git rev-list display version range
Git show-branch displays a list of branches and topological relationships
Git show-ref displays local references
Git symbolic-ref displays or sets symbolic references
The point to which the git update-ref update reference
Git verify-tag verifies the Tag of GPG signature
4. Commands related to version library management
Brief description of the command
Git count-objects shows the number of loose objects and disk footprint
Refactoring of git filter-branch version Library
Git fsck object library integrity check
A synonym for git fsck-objects*, equivalent to git fsck
Storage optimization of git gc version library
Git index-pack creates the corresponding index file from the packaged file
Git lost-found* is out of date, please use the git fsck-lost-found command
Git pack-objects reads the object ID from standard input and packages it to a file
Git pack-redundant finds redundant pack files
Git pack-refs packages references into the. git/packed-refs file
Git prune removes expired objects from the object library
Git prune-packed deletes loose objects that have been packaged
Git relink establishes a hard connection for the same objects in the local version library
Git repack packages loose objects that are not packaged in the version library
Git show-index reads the index file of the package and displays the contents of the package file
Git unpack-objects releases files from packaged files
Git verify-pack check object library package file
5. Commands related to data transmission
Brief description of the command
Git fetch-pack executes this command locally when executing a git fetch or git pull command to get missing objects from other version libraries
A command executed remotely when git receive-pack executes a git push command to receive pushed data.
A command executed locally when git send-pack executes the git push command to push data to other versions of the library
When git upload-archive executes 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 executes this command remotely when executing a git fetch or git pull command to package and upload objects
6. Mail-related commands
Brief description of the command
Git imap-send sends patches over IMAP
Git mailinfo exports submission instructions and patches from email
Git mailsplit extracts messages from mailboxes in mbox or Maildir format into files one by one
Git request-pull creates information containing the differences between submissions and the address where the PULL operation is performed
Git send-email sends mail
7. Protocol-related commands
Brief description of the command
Git daemon implements Git protocol
Git http-backend implements the CGI program of HTTP protocol and supports intelligent HTTP protocol.
Git instaweb instantly launches 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 updates the auxiliary files required by the dumb protocol
Git http-fetch acquires the version library through HTTP protocol
Git http-push pushes via HTTP/DAV protocol
Git remote-ext is called by the Git command and provides extended protocol support through external commands
Git remote-fd is called by the Git command, using the file descriptor as the protocol interface
Git remote-ftp is called by the Git command to provide support for the FTP protocol
Git remote-ftps is called by the Git command to provide support for the FTPS protocol
Git remote-http is called by the Git command to provide support for the HTTP protocol
Git remote-https is 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
Brief description of the command
Git archimport imports Arch version library to Git
Git bundle submits packaging and unpacking for delivery between different versions of libraries
Git cvsexportcommit checks out a submission of Git as a CVS
Git cvsimport imports the CVS version library into Git. Or use cvs2git
Git cvsserverGit's CVS protocol simulator, which provides CVS commands with access to Git version libraries
Git fast-export exports the submission to git-fast-import format
General tools for migrating git fast-import other version libraries to Git
Git svnGit as the front-end operation Subversion
9. Merge related auxiliary commands
Brief description of the command
Git merge-base is called by other scripts to find the most recent common ancestor of two or more submissions
Git merge-file performs a three-way file merge for two different versions of the file
Git merge-index invokes the specified conflict resolution tool for conflict files in index
Git merge-octopus merges more than two branches. See git merge's octopus merge strategy
Git merge-one-file A standard helper program called by git merge-index.
Git merge-ours merge uses the local version and throws away other people's versions. See git merge's ours merge strategy
Git merge-recursive is for a three-way merge of two branches. See git merge's recursive merge strategy
Git merge-resolve is for 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 is called by the script that performs the merge operation to create a merge submission description
Git rerere reuses recorded conflict resolution
10. Miscellaneous
Brief description of the command
Git bisect-helper is called by the git bisect command to confirm the progress of the binary search.
Git check-attr shows whether a file has a property set
Git checkout-index copies files from the staging area to the workspace
Git cherry looks for submissions that are not merged into the upstream
Git diff-files compares the staging area with the workspace, which is equivalent to git diff- raw
Git diff-index compares temporary storage area with version library, which is equivalent to git diff- cached-raw.
Git diff-tree compares two tree objects, which is equivalent to git diff- raw A B
Git difftool-helper is called by the git difftool command, and the difference comparison tool to be used by default
Git get-tar-commit-id extracts and submits ID from the tar package created by git archive
Get user password input interface for git gui-askpass command git gui
Git notes submission comment Management
Git patch-id patch filters line numbers and white space characters to generate patch unique ID
Git quiltimport applies the Quilt patch list to the current branch
Git replace submit replacement
Summary output of git shortlog to git log, suitable for product release notes
Git stripspace deletes blank lines for other scripts to call
Git submodule submodule management
Git tar-tree obsolete command, please use git archive
Git var displays Git environment variables
Git web-browse launches a browser to view directories or files
Git whatchanged displays the submission history and the changes submitted each time
Git-mergetool-lib is included in other scripts to provide the selection and execution of merge / difference comparison tools
Git-parse-remote is included in other scripts and provides functions to manipulate the remote version library
Git-sh-setup is included in other scripts and provides a library for shell programming
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
The above is all the contents of this article "what are the Common git commands?" 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.