场景

1.将已有项目代码纳入Git管理

1
2
cd 项目代码所在文件
git init

2.新建的项目直接用Git管理

1
2
3
cd 某个文件夹
git init your_project # 会在当前路径下创建和项目名称同名的文件夹
cd your_project
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 G:\mygitea\GitLearn\0-material 
$ vi Readme.md

G:\mygitea\GitLearn\0-material   master ± 
$ cd ..

G:\mygitea\GitLearn   master ± 
$ git add .
warning: LF will be replaced by CRLF in 0-material/Readme.md.
The file will have its original line endings in your working directory

G:\mygitea\GitLearn   master ± 
$ git status
On branch master

No commits yet

Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: 0-material/Readme.md


G:\mygitea\GitLearn   master ± 
$ git config --local user.name "Jabari"

G:\mygitea\GitLearn   master ± 
$ git config --local user.email "innocenfox@gmail.com"

G:\mygitea\GitLearn   master ± 
$ git commit -m "Add Readme"
[master (root-commit) fecfd50] Add Readme
1 file changed, 3 insertions(+)
create mode 100644 0-material/Readme.md