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/03 Report--
The git of this article is version 1.9.6:
I. git global configuration
2. Git initializes the local warehouse
III. Detailed explanation of the status of git files
IV. Undo and restore operations of git files
The git submission process is as follows:
Git repository sees the online code centralized management server; that is, the last location of our code
Git staging area is regarded as our local code centralized management server, and can be regarded as the intermediate temporary zone of code (relative to repository)
Git working directory is regarded as our locally edited code, that is, the code editing office.
1: global configuration
Leo@LEO-PC / d/User/leo/Desktop/git (master) $git config-global user.name "lansgg" leo@LEO-PC / d/User/leo/Desktop/git (master) $git config-global user.email "coffee_lanshan@sina.com"
The configuration-- global option here is actually modifying the .getconfig file in the home directory.
Such as mine:
C:\ Users\ leo\ .getconfig
Content:
[user] name = lansgg email = coffee_lanshan@ Sina.com [color] ui = true [core] autocrlf = true excludesfile = C:\\ Users\\ leo\\ Documents\\ gitignore_global.txt
When we modify this file, such as name=test (the content has been modified)
$git config-get user.name
The user name and email address here are identified when the code is submitted, showing the author's information.
2: initialize the local git repository
Create a new directory locally; execute git init
$mkdir git$ git init
The change after implementation is the addition of a .git directory
Leo@LEO-PC / d/User/leo/Desktop/git (master) $ls-a. Git. COMMIT_EDITMSG config hooks info objects.. HEAD description index logs refsleo@LEO-PC / d/User/leo/Desktop/git (master) $
Git directory, which stores the document index content we submitted. Git can track the content of the document it manages based on the document index content, so as to realize the version control of the document. The .git directory is located in the working directory.
Index (index): takes a snapshot of all files (including subdirectories) under the working directory and stores them in a temporary storage area, which Git calls an index.
3. Detailed explanation of the status of git files
3.1.Now build our code
Leo@LEO-PC / d/User/leo/Desktop/git (master) $touch README.txtleo@LEO-PC / d/User/leo/Desktop/git (master) $cat hello.rbputs "hello world!"
We need to submit he.rb and README to the local git repository
3.2. Check the status of the file first
$git status
Or
$git status-s
According to the output information, we can see that the two README.txt hello.rb files are in the master branch (main branch), and these two files are untracked files, so we will not submit them to git repository when we execute the git commit (for submitting to the warehouse in the figure) command.
The figure-s above indicates brief information; two question marks are also of great significance.
The first one? It mainly represents the file changes between staging area and repository, usually with two letters (A, M); An indicates that the file is already tracking the file, and M indicates that the file has been modified in the staging area area and has not been submitted to repository.
The second one? Mainly indicates the file changes between working directory and staging area. M indicates that the file has been modified in the working directory area and has not been submitted to staging area.
Let's start the demonstration: git add means to track the file.
$git add README.txt$ git add hello.rb
Check the file status again
$git status-s
You can see that the two files are already in state A (tracking). Now the two files are in the staging area area; changes to be committed can submit them; output information indicates that you can use git reset HEAD to restore the files to the untracked state.
Return to the state that has been tracked and conduct a submission test
$git commit-m "first commit" #-m means to describe when this code is submitted; we describe it here as "first commit"
You can see that wording directory clean is not outputting anything when it has submitted these two files to repository; (from the staging area area) and checked the file status
3.2 modify the local code, and then check the file status
$echo 'puts "hello world!" > hello.rb$ git status-s
The second one? M indicates that the file has been modified in the working directory area; the output message indicates that the hello.rb file has been modified; the command git add & & git checkout & & git commit-a (shown in the figure)
How to submit this file to repository
$git add hello.rb$ git commit-m "second commit" hello.rb
Or use:
$git commit-a-m "second commit"
This command will skip the git add step ~
4. Revocation and reinstatement
4.1. modify the code of the local working directory; then undo the modification, that is, remove the code from the staging area area to overwrite the code of the current working directory
The tests are as follows:
$echo 'puts "hello world!" > hello.rb # modify the local code$ git status-s # to view the status of the file, there is a difference $git checkout hello.rb # take the code$ git status-s from the staging area area to view the status of the file again, there is no difference, and the code is restored to the previous code
4.2. Modify the code of the local working directory and track it (add to the staging area area). Then if we want to undo the changes to the local code, we can pull the code from the repository warehouse to staging area, and then extract the code from the staging area area to cover the working directory area. The tests are as follows:
$echo 'puts "hello world!"> hello.rb$ git status-s $git add hello.rb$ git status-s $git reset hello.rb$ git status-s $git checkout hello.rb$ git status-s # checks file status differences at each step
We can also pull it directly from the repository area and cover it directly to the working directory area without so much trouble:
$echo 'puts "hello world!"> hello.rb$ git status-s $git add hello.rb$ git status-s $git checkout HEAD hello.rb$ git status-s
You can see that this file has been pulled from git repository and overwritten ~
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.