In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to install and use Git. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Git install and use $yum-y install git / / install git$ git-- version / / verify questions about git clone permissions $cd ~ / .ssh # if you don't have a key, you won't have this folder, backup delete # generate key: $ssh-keygen-t rsa-C "dev@chuchur.com" # Press 3 enter, the password is empty. # finally got two files: id_rsa and id_rsa.pub# add key to ssh:$ ssh-add ~ / .ssh/id_rsa (need to enter password before) # add id_rsa.pub content to gitlib or github$ cat id_rsa.pub# to get some common commands about git
The rules come into force
# the solution to the ineffectiveness of Git ignore rules and .gitignore rules $git rm-r-cached. # # recommended practice, then git commit, git push#git rm-cached deletes the tracking status, not the physical file; if you really don't want it at all, you can also directly rm# the common practice $git update-index-assume-unchanged # tell git, leave me alone, even if I change, you don't see it, switch branches fail $git update-index-no-assume-unchanged # tell git, come on, have fun. I changed, $git update-index-- skip-worktree # told git, don't screw me from now on, life or death has nothing to do with you.
Version management
# Save the password locally so that you don't need a password every time you synchronize the code (use with caution) $git config credential.helper store$ git config-- global user.name "username" # set user name $git config-- global user.email "email" # set user mailbox # create remote branch $git checkout-b dev # New local branch $git push origin dev:dev # push to remote branch # Delete branch $git branch-D dev # Delete local branch $git push origin: dev # Delete remote branch Push an empty branch to remote branch $git push origin-delete dev# delete remote branch # switch branch $git branch-a # View the list of branches, do not see the latest branch, execute git pull$ git checkout-b dev origin/dev # to get the remote branch local and switch $git checkout dev# to dev# to discard cleaning local changes $git checkout. & & git clean-xdf# cache operation $git add | git add-A | git add. # add to the cache $git commit-m 'function development completed' # add comments $git reset HEAD # the cache is returned to the workspace. Before there is no commit, it has been git add$ git checkout-- | git checkout. # discard workspace changes, no git add
Version returned
$git reflog # check the commit version $git reset-- soft # switch back to the version, the local code will not change, just change the version number $git reset-- hard # switch back to the version, the local code will change, the version number will also change, be careful to use $git reset-- soft HEAD~1 # already add, and commit, do not want to push, you can do this, directly switch back to the previous version $git reset-soft head ^ # ditto, note Simply withdraw the commit operation, and the code you write remains. $git rm-- cached | git clean-xdf # discards the local or other $git push origin-- force # plus-- force overwrites the remote branch, because the local version is lower than the online version after the returned version and cannot be submitted
-- mixed: does not delete the workspace change code, undoes commit, and undoes git add. Operation this is the default parameter, git reset-- mixed head ^ and git reset head ^ have the same effect. -- soft: do not delete the workspace change code, undo commit, do not undo git add. -- hard: > Delete the workspace change code, undo commit, undo git add. Notice that after completing this operation, you are back to the previous commit state.
Modify comment
If the commit comment is written wrong, just want to change the comment, just need: git commit-- amend, at this time will enter the default vim editor, modify the comment and save it.
Related use of Gerrit
# submit the code $git pull# to master$ git push origin HEAD:refs/for/master# and submit to dev-001$ git push origin HEAD:refs/for/dev-001
There is some difference between gerrit and git, that is, every time the push code must keep up with the code branch, otherwise it will be submitted to master by default.
This is the end of the article on "how to install and use Git". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.