Git is the world's most advanced distributed version control system
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
The above code, command --global
parameter indicates all of the Git repository on your machine will use this configuration.
pwd
Command is used to display the working directory path name, full name is "Print Working Directory"
By git init
command becomes the catalog can manage Git repository, as follows, enter:
git init
Output is as follows:
Initialized empty Git repository in C:/Users/Re:CREATORS/Cortana/.git/
Current directory more than a .git directory, and this directory is to track and manage Git repository.
If you do not see the .git
directory, it is because this directory is hidden by default, with the following code can be seen:
ls -ah
Git add command tells Git, to add files to the repository:
git add readme.txt
Command git commit
tells Git, the submission of documents to the repository:
git commit -m "wrote a readme file"
git commit
Command, -m
entered followed by explanation of this submission, you can enter any of the content, of course, the best is meaningful, so you can from the history list easy to find change records
The code output is as follows:
[master (root-commit) 32f63de] wrote a readme file
1 file changed, 3 insertions(+)
create mode 100644 readme.txt
git commit
After the successful implementation of the command will tell you 1 file changed
: a file is changed (we readme.txt file newly added); : 2 insertions
insert the two lines (readme.txt have two lines).
Why add files Git needs add
, commit
a total of two steps it? Because commit
it can submit many files at once, so you can multiple add
different files, such as:
git add file1.txt
git add file2.txt file3.txt
git commit -m "add 3 files"
summary
Summarize the contents of two learned today:
Initialize a Git repository, use the git init
command.
Add files to the Git repository, in two steps:
- Using the command
git add <file>
, pay attention, it can be used repeatedly to add multiple files; - Use the command
git commit -m <message>
to complete.