In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the summary of Git operation commands under the Linux system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn the "summary of Git operation commands under the Linux system"!
1. Display current configuration information
The code is as follows:
Git config-list
two。 Create repo
Get it from somewhere else
The code is as follows:
Git clone git://git.kernel.org/pub/scm/git/git.git
Build on your own
The code is as follows:
Mkdir test
Cd test
Git init
3. Display statu
The code is as follows:
Git status
4. Commit
Git add file.1 file.2 first adds files to index. Only in this way can you know which files to commit when you commit.
Or
The code is as follows:
Git add-p
Used by interactively to select which changes need to be commit
The code is as follows:
Git commit-m "log message"
Or
The code is as follows:
Git commit-a
Automatically check what files should be commit. If it is a new file, you will still use git add to add it.
5. Show previous work
The code is as follows:
Git log
Output format
The code is as follows:
Git log
The code is as follows:
Git log-p
Show patch
The code is as follows:
Git log-stat
Show a summary of the changes
The code is as follows:
Git log-graph
Displays only the current branch
The code is as follows:
Git log-graph-all
Show all branch's
The code is as follows:
Git log-graph-all-decorate
Display the name of branch
The code is as follows:
Git log-- pretty=oneline, short, full, fuller
The log form of the output is different
The code is as follows:
Git log-- pretty=format: "% h -% an,% ar:% s"
Output in the specified format.
For other options for-- pretty and specific format formats, refer to the PRETTY FORMAT section in git log-- help.
The code is as follows:
Git log-follow file.c
This feature is interesting, especially when file.c is moved.
Usually we move a file to a directory. If you do so, git log will not be able to display records before the directory is moved.
Then add-- follow.
Screening of git log
Git log-2-p shows the log and diff of the last two commit
Git log-author= "Author Name" to screen the log of specific authors
Git log-- since= "2012-2-23"-- before= "2012-2-24" screening period
Git log-- grep= "key word" looks for keywords in commit's message
Git log branch-not master views records on branch but not on master.
Git log-S "func_name" looks for a character that appears or is removed from the commit. For example, you can find out when a function was added or deleted.
Git show sha1 this sha1 is the sha1 of each commit, which displays complete information about a commit, including diff
6. Undo changes
The code is as follows:
Git checkout-file.1
Undo this change in file.1. Just undo the changes without staged.
The middle-- indicates that this is a file, not a branch name.
The code is as follows:
Git reset-hard HEAD
Undo all changes without commit, including those without stage and those without stage.
The result of this order is the same.
Git checkout HEAD file.1
Both staged and non-staged will be cleared.
Sometimes we find that we have a problem with making a commit before. We don't want it. We want to get rid of it.
Git revert HEAD automatically has to do a new commit to return the last commit.
Git revert head ^ automatically has to do a new commit to return the last second commit.
7. Delete a commit
The code is as follows:
Git reset-hard HEAD~1
Deleted the most recent commit
8. Modify the most recent commit
The code is as follows:
Git commit-amend
7. Show changes made
The code is as follows:
Git diff
Show all changes. There is no add into index.
The code is as follows:
Git diff-staged or git diff-cached
Show staged changes, that is, add things, that is, things that are going to commit.
The code is as follows:
Git diff commit1 commit2
Shows the changes between the two commit, from commit1 to commit2.
The code is as follows:
Git diff commit1..commit2
Two points, the effect is the same as the one above.
The code is as follows:
Git diff commit1...commit2
The three dots represent the changes that took place in the commit2 branch all the way to the common father of commit1 and commit2.
The code is as follows:
Git blame-C file1.c
Show the specific changes to the file. Well, it seems to be used to find whose fault it is?
The code is as follows:
Git blame-Ln,m file1.c
Look at the changes between the two lines of npen m.
The code is as follows:
Git blame commit1~1-Ln,m file1.c
Check the changes before the commit1 version. Track down the previous log.
The code is as follows:
Git blame commit1~1-Ln,m-- old/file.c
If the file has been renamed or moved to a location, enter the name of the old file.
And you have to add-- definitely.
8. Delete a file
The code is as follows:
Git rm file-name
Delete this file from the library and the current working directory
The code is as follows:
Git rm-cached file-name
Delete only from the library, leaving the current local file.
9. Rename a file
The code is as follows:
Git mv file file-new
10. Apply patch
The code is as follows:
Git apply patch-file
To do so, apply the patch from the patch-file. The effect is similar to the patch command.
But the upside is that git apply either succeeds or doesn't. Do not want to patch, there may be some patch hit, but some did not hit.
After git apply, there is no automatic generation of commit.
Git apply-check can be used to detect whether the patch will conflict or fail.
The code is as follows:
Git am patch-file
This is a command designed specifically for git. Patch-file is generated through git format-patch.
It contains the author's information and a brief description.
After git am, a commit is automatically generated.
The code is as follows:
Git am-resolved
There may be conflict in the git am process. If you encounter conflict, you need to modify code and git add manually.
Use git am-- resolved
11 delete some files without git add
The code is as follows:
Git clean
Parameters.
-n displays the files and directories to be deleted
-f Delete files
-df deletes files and directories
The code is as follows:
Git clean-df alps/
Git remote
Git is a distributed code management tool, so it can support multiple repositories. In git, the repository on the server is called remote locally.
Directly clone a warehouse:
The code is as follows:
$: git clone git@search.ued.taobao.net:projects/search.git
Another way of clone:
The code is as follows:
# create a directory to initialize the local repository
$: mkdir search & & cd search
$: git init
# add remote warehouse path
$: git remote add github git@github.com:yyfrankyy/search.git
# in fact, pull is fetch + merge
$: git pull github-all-tags
Migrate the working directory to github:
The code is as follows:
$: git remote add github git@github.com:yyfrankyy/search.git
$: git push github-all-tags
Show all remote warehouses
The code is as follows:
$: git remote-v
Origin git@search.ued.taobao.net:projects/search.git (fetch)
Origin git@search.ued.taobao.net:projects/search.git (push)
Github git@github.com:yyfrankyy/search.git (fetch)
Github git@github.com:yyfrankyy/search.git (push)
Rename remote warehouse
The code is as follows:
$: git remote rename github gh
$: git remote
Origin
Gh
Delete remote warehouse
The code is as follows:
$: git remote rm github
$: git remote
Origin
Grab data from the remote warehouse and update the local warehouse:
The code is as follows:
$: git fetch origin
Remote: Counting objects: 58, done.
Remote: Compressing objects: 100% (41 amp 41), done.
Remote: Total 44 (delta 24), reused 1 (delta 0)
Unpacking objects: 100% (44amp 44), done.
From git://search.ued.taobao.net:projects/search.git
* [new branch] product-> origin/product
View remote warehouse information, which can be used to track other people's push:
The code is as follows:
$: git remote show origin
* remote origin
Fetch URL: git@search.ued.taobao.net:projects/search.git
Push URL: git@search.ued.taobao.net:projects/search.git
HEAD branch: master
Remote branches:
Master tracked
P4popt tracked
Prepub tracked
Product tracked
Local branches configured for 'git pull':
Master merges with remote master
P4popt merges with remote p4popt
Prepub merges with remote prepub
Product merges with remote product
Local refs configured for 'git push':
Master pushes to master (up to date)
P4popt pushes to p4popt (up to date)
Prepub pushes to prepub (up to date)
Product pushes to product (up to date)
At this point, I believe you have a deeper understanding of the "summary of Git operation commands under the Linux system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.