In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the sharing of 15 practical Git commands, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
1. Modify the most recent submission
Git commit-amend
Amend allows you to attach periodic changes (such as adding forgotten files) to your last submission. Adding-- no-edit will modify the final submission without changing its commit message. If there are no changes,-- amend will allow you to re-enter the final submission message.
two。 Add selected parts of the file interactively
Git add-p
-p (or-patch) allows you to interactively select the parts of each trace file to be submitted. In this way, each commit contains only the relevant changes.
3. Hide selected parts of the file interactively
Git stash-p
Similar to git-add, you can use the-- patch option to interactively select each part of the file to be tracked.
4. Hide untracked files
Git stash-u
By default, untracked files are not included in storage. To change this behavior and include those files, you need to use the-u parameter. There is also a-a (- all) parameter that stores all untracked and ignored files, which is usually something you don't need.
5. Restore selected parts of the file interactively
Git checkout-pmurf-patch` can be also used to selectively discard parts of each tracked file. I aliased this command as `git discard
6. Switch to the previous branch
Git checkout-
This command allows you to quickly switch to previously checked out branches. Usually-is an alias for the previous branch. It can also be used with other commands. I created an alias co for checkout, so it could be git co-
7. Restore all local changes to git checkout.
If you are sure you can discard all local changes, you can use. One at a time. But it's a good habit to always use checkout-- patch.
8. Show changes
Git diff-staged
This command displays all phased changes (changes that have been added to the index), while git diff displays only changes in the working directory (no changes in the index).
9. Rename the branch locally
Git branch-m old-name new-name
If you want to rename the currently checked-out branch, you can shorten the command to the following form:
Git branch-m new-name
10. Remotely rename branch
To rename the branch remotely, after renaming the branch locally, you need to remotely delete the branch and then push the renamed branch again.
Git push origin: old-namegit push origin new-name
11. Open all conflicting files at once
Resetting the benchmark may lead to conflicts, and the following command will open all files that require you to resolve these conflicts.
Git diff--name-only-- diff-filter=U | uniq | xargs $EDITOR
twelve。 What has changed?
Git whatchanged-since='2 weeks ago'
This command displays a log containing the differences introduced by each commit in the last two weeks.
13. Delete a file from the previous submission
You can quickly delete missubmitted files from the last submission by combining rm with the commit-- amend command:
Git rm-cached git commit-amend
14. Find branches
Git branch-contains
This command displays all branches that contain a specific submission.
15. Optimize the repository locally
Git gc-prune=now-aggressive
Summary
Although I like CLI very much, I strongly recommend using Magit to further improve your efficiency in using Git. It is one of the best software I have ever used.
You can also view a wonderful overview of the Git workflow through the help command. Be sure to read it carefully!
Git help workflows thank you for reading this article carefully. I hope the article "sharing 15 practical Git commands" shared by the editor will be helpful to you. At the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you 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.