In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the "tutorial on the installation of Git client in Ubuntu system and the use of basic commands". In daily operation, it is believed that many people have doubts about the installation of Git client in Ubuntu system and the use of basic commands. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about the installation of the Git client in the Ubuntu system and the use of basic commands. Next, please follow the editor to study!
Install git
The code is as follows:
Sudo apt-get install git
The-- global parameter of the git config command, which means that all Git repositories on your machine will use this configuration. Of course, you can also specify a different user name and Email address for a warehouse.
The code is as follows:
Git config-global user.name "Your name"
Git config-global user.email "email@XX.com"
Create a version library repository
First find a place, create an empty directory, and then use the git init command
The code is as follows:
Git init
Put the files in the built warehouse directory and use the following command
Use add to add files to the warehouse
The code is as follows:
Git add filename
Use commit to tell git to submit the file to the warehouse
The code is as follows:
Git commit-m "input something"
The successful execution of the git commit command will tell you how the file has been changed. Commit can submit many files at a time
View warehouse history
The git status command allows us to keep track of the current state of the warehouse.
The code is as follows:
Git status
Git diff filename can see how the file was modified.
Version fallback
Use the git log command to view history
The code is as follows:
Git reset-- hard + version number
Where * * HEAD represents the current version, head ^ represents the previous version, and head ^ ^ indicates that the previous version can also be written as a hundred versions on HEAD~100. You don't have to write all the version numbers, just write the first few places. Git will automatically help you find it.
Use git reflog to view the record of your every operation.
Undo the modification
Use
The code is as follows:
Git checkout-xxx.txt
The command git checkout-- readme.txt means to undo all changes to the readme.txt file in the workspace. There are two situations:
One is that readme.txt has not been placed in the temporary storage area since it was modified. Now, if you undo the changes, you will return to exactly the same state as the version library.
One is that after readme.txt has been added to the staging area, it has been modified, and now the undo changes return to the state after being added to the staging area.
In short, let the file go back to the state it was in when it was last git commit or git add
Using git reset HEAD + filename, you can undo the changes to the staging area and put it back into the workspace. The git reset command can either roll back the version or undo changes to the staging area.
Delete a file
* * use git rm filename** to delete files
If you delete it incorrectly, you can use git checkout-- filename to restore it.
View, switch, create, and delete branches
The code is as follows:
Git br-r # View remote branches
Git br # create a new branch
Git br-v # View the final submission information of each branch
Git br-- merged # View branches that have been merged into the current branch
Git br-- no-merged # View branches that have not been merged into the current branch
Git co # switch to a branch
Git co-b # create a new branch and switch over
Git co-b # create a new new_branch based on branch
Git co $id # checkout a history submission record without branch information. Switching to another branch will delete it automatically.
Git co $id-b # checkout a history submission record and create a branch
Git br-d # Delete a branch
Git br-D # forcibly delete a branch (it is mandatory when an unmerged branch is deleted)
Branch merging and rebase
The code is as follows:
Git merge # merges the branch branch into the current branch
Git merge origin/master-- no-ff # do not merge with Fast-Foward, which can generate merge submission
Git rebase master # master rebase to branch, which is equivalent to:
Git co & & git rebase master & & git co master & & git merge
Git staging management
The code is as follows:
Git stash # temporary storage
Git stash list # column all stash
Git stash apply # restore temporarily stored content
Git stash drop # Delete staging area
Remote warehouse
Create SSH key
The code is as follows:
Ssh-keygen-t rsa-C "email@xx.com"
If all goes well, you can find the .ssh directory in the user's home directory, which contains two files, id_rsa and id_rsa.pub, which are the key pairs of SSH Key. Id_rsa is the private key and cannot be leaked out. Id_rsa.pub is the public key and can be safely told to anyone.
Log in to GitHub and open the "Account settings", "SSH Keys" page:
Then, click "Add SSH Key", fill in any Title, and paste the contents of the id_rsa.pub file in the Key text box
Push the local warehouse to the GitHub warehouse
The code is as follows:
Git remote add origin git@github.com:pastqing/wangdao.git
Git push-u origin mastercd
Because the remote library is empty, when we push the master branch for the first time, we add the-u parameter. Git will not only push the local master branch content to the remote new master branch, but also associate the local master branch with the remote master branch, so that the command can be simplified when pushing or pulling later.
Since then, after each local submission, you can use the command git push origin master to push the latest changes whenever necessary
Cloning from a remote warehouse
The code is as follows:
Git clone git@github.com:pastqing/wangdao.git
View submission record
The code is as follows:
Git log
Git log # View the record of each submission of the file
Git log-p # View the diff of each detailed modification
Git log-p-2 # View the diff of the last two detailed modifications
Git log-stat # View submission statistics
At this point, the study on "the installation of Git client in Ubuntu system and the use of basic commands" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.