In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Git version 1.9.6 of this article
Git code submission hierarchy diagram
First, modify the local code to view the differences
Remove the code
III. Rename code
1.1.When we modify the local code, we can see that the state of the file is in the modified state by using the command; then we can commit the code add
We can see what code has changed and what has been changed.
$git status-s $echo 'puts "hello world!" > hello.rb$ git diff hello.rb
Add this to the staging area area and check the file status again
$git add hello.rb$ git status-s $git diff hello.rb
You can see that the file status indicates a change between the staging area and repository areas
You can see that the diff option can be used to view file changes between working directory and staging area regions
1.3.Using git diff HEAD, you can see the file changes between working directory and repository regions
$git diff HEAD hello.rb
1.4.Using git diff-staged, you can see the file changes between staging area and repository regions
$git diff-staged hello.rb
$git diff-- staged-- stat hello.rb # output brief information
This is the command to change the output of the file.
2. Remove the code
2.1.Delete the file of hello.rb, (this step is equivalent to the reverse operation of add) to check the file status; commit the result to repository; to check the file status
$git rm hello.rb$ ls$ git status-s
You can see that the local files have been deleted when rm is executed.
If you execute status, you can see that the file status identified as D indicates that the process has been deleted.
$git commit-m "first del" hello.rb
2.2.If we do not want to delete the files in the working directory area, but only want to delete the files in the staging area area, we can execute the git rm-- cached command
$git rm-cached hello.rb
After executing git status-s, D and?? What does it mean? D represents the difference between the staging area and repository regions, indicating that the hello.rb handles deletion, so the hello.rb in the working directory region is in the Untracked state
2.3.If you want to restore the hello.rb in the staging area area, you can pull it from repository or submit it from working directory (if there is no change locally, the new file will be submitted and the previous file will not be restored)
$git reset hello.rb # pull from repository
3. Rename the code
Rename the local file README.txt to README.md, check the file status, and then submit it to repository
$git mv README.txt README.md$ git commit-m "first rename filename"
Tips: when you execute commit above, you actually perform two steps: delete and submit the README.txt and submit the README.md. You can see it in the figure below.
In fact, in git, the name and content of a file can be understood separately (like the variables and values of Python); in git, if the contents of two files are the same, he thinks it is a rename
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.