In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what is the function of git command in linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what is the function of the git command in linux?"
Preface
The HEAD pointer always points to the latest version number of the current branch, and the number n or HEAD~n,n of head ^, head ^ ^, ^ represents the first n version numbers.
Using linux rm directly in the project only deletes the workspace files, git rm deletes the workspace files at the same time as the stage, or uses git rm-- cached to delete only the stage files.
Some basic operations
# Global configuration git config-- global user.name "your username" git config-- global user.email youremail@email.comgit config-- global color.ui true#mkdir git_proj & cd git_projgit initecho "# readme.md" > > README.mdgit add README.mdgit commit-m "readme commit" # add a remote warehouse and give it an individual name origingit remote add origingit @ github.com:username/repositoryName.git# push the local warehouse to the master branch of origin and associate it with this branch (the role of-u) Later, you don't have to use) git push-u origin master# gets the latest source code from the master branch of the remote warehouse origin and downloads it to the tmp branch git fetch origin master:tmp# compared to the changes made by the tmp branch to the master branch git diff master tmp# merges the tmp branch to the master branch git merge tmp# clone copy a complete remote warehouse to the local git clone git@github.com:username/repositoryName.git# pull to obtain the master branch of origin and directly Merge with the current branch # so a conflict may occur git pull origin master
Checkout
The checkout command has two main functions: switching branches and rolling back files to the current stage or repository version
1. Switch branches
# switch to new_branch branch git checkout new_branch# creation and switch to new_branch branch git checkout-b new_branch
2. Roll back the workspace files to the latest stage version or repository version, that is, check out the latest version from stage or repository
#-- is the parameter after the file identifier table name to avoid ambiguous git checkout for the file to switch branch--
When rolling back, you will first check whether there is a corresponding file in stage, and if not, the latest version in repository will be used. When a file has been modified and add many times, we can only roll back the file to the latest version of add with checkout.
But in some scenarios we might want to roll back to the latest version of repository. How do we do that? It can be easily done with the reset command.
Give the order first:
Git reset HEAD & git checkout-
This allows you to roll back the filename of the workspace to the latest version in repository. We will explain the specific principle in detail in an example.
Reset
Git's reset command is rather circumspect and requires patient understanding. In a nutshell, reset has three reset levels, and we need to understand exactly what each level does.
Soft: return the version number. Act on repository
Mixed: return the version number and reset stage. Acting on repository and stage
Hard: return the version number, reset stage, and reset the workspace source code. Acting on repository,stage and workspace
Let's briefly show the version number of repository, which we use as demo to try three levels of reset.
Git logversion D (HEAD)
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.