Professional Documents
Culture Documents
Li Yanrui
v 0.1, 20080728
liyanrui.m2@gmail.com
Git
Git
(Version
Control System)
1 Git Git
2 Git
3 Git
4 Git FAQ
Git
Contents
1
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
Git
Git
Git
1
1
1
2
3
4
5
7
7
8
2
2.1
2.2
2.3
2.4
2.5
Git
M2GE
9
9
10
12
12
13
3
3.1
3.2
3.3
3.4
M2GE
14
14
15
15
16
Git
Git Git
Git
1.1
Git
Git
Git
Git
Git
1.2
Git
Git
TEX TEX $HOME/work/m2doc
Bash $WORK Git
$ cd $WORK
$ git init
Git
Initialized empty Git repository in $PROJECT/.git/
$WORK .git
Git $WORK
Git Git
$ cd $WORK
$ git add .
Git
git-commit
git-commit
$ git commit
git-commit Git
git-commit -m
$ git commit -m ""
Git 1.1
git-add
git-init
1.1
git-commit
Git
1.3 Git
Git
$ git config --global user.name "Your Name Comes Here"
$ git config --global user.email you@yourdomain.example.com
Git
zh
zh TEX
Git Git
Git .gitignore
zh $WORK
$ cd $WORK
$ echo "zh" > .gitignore
$ git add .
gitignore
$ man gitignore
1.4
Git .git
Git
.git $WORK
$ cp -R $WORK/.git /tmp/m2doc.git
$ cd /tmp
$ git clone m2doc.git m2doc-copy
$WORK .git /tmp
m2doc.git git-clone 1 m2doc.git m2doc-copy
m2doc-copy
$WORK
m2doc.git
m2doc-copy/.git
Git
1.5
Git
Git
Git
$ cd $WORK
$ git add ch1.tex
Git ch1.tex
doc-env.tex git-tutor.tex
git-add
$ git add doc-env.tex git-tutor.tex
git-commit
$ cd $WORK
$ git add .
$ git commit -a
... ...
git-add
git-commit -a
Git git-add
Git
Git
1.6
git-log
git-commit
$ git log
git-log
commit dfb02e6e4f2f7b573337763e5c0013802e392818
Author: Li Yanrui <LiYanrui.m2@gmail.com>
Date: Wed Jul 9 16:32:25 2008 +0800
Git
commit 9a4a9ce37561bbb42d8187d7a851e228e26e1212
Author: Li Yanrui <LiYanrui.m2@gmail.com>
Date: Wed Jul 9 16:31:07 2008 +0800
.gitignore
commit 459640624390eb733fb2ad45bcb8731435931e60
Author: Li Yanrui <LiYanrui.m2@gmail.com>
Date: Wed Jul 9 16:28:50 2008 +0800
M2Doc
lines 1-17/17 (END)
M2Doc
Git
git-show
1.7
git-reset
--mixed git-reset
--soft
git-reset
Git --mixed --soft
git-reset git-status
git-reset git-reset
1.8 Git
git-reset
git reset
git reset
$ man git-reset
1.9
Git
Git Git
Git
Git
Git
2.1
Lyr Tzc Lyr M2GE
1 Git M2GE Git
Lyr
Tzc
M2GE
Lyr M2GE /work/m2ge Tzc Lyr
$ cd work
$ git clone lyr@192.168.0.7:~/work/m2ge m2ge
git-clone Git
Tzc SSH Lyr lyr
M2GE m2ge
git-clone Tzc Lyr
M2GE Tzc m2ge
git-clone
SSH
@IP:
Tzc M2GE
Lyr
M2GE M2GE
1
Git
Lyr
Tzc
Git
Tzc Lyr
$ cd ~/work/m2ge
$ git pull tzc@192.168.0.5:~/work/m2ge
git-pull
Lyr Tzc
2.2
Lyr Tzc foo.txt
foo.txt
one
two
three
Lyr foo.txt
ONE
two
three
Tzc foo.txt
one
two
THREE
10
Tzc foo.txt
one ONE
two
three
foo.txt Git
Auto-merged foo.txt
CONFLICT (content): Merge conflict in foo
Automatic merge failed; fix conflicts and then commit the result.
foo.txt
Lyr
foo.txt
<<<<<<< HEAD:foo
ONE
=======
one ONE
>>>>>>> 1116d3270764d91a25532a753a47b8b0e1b6f1b8:foo
two
three
< Lyr foo.txt
> Tzc foo.txt
= Lyr
Tzc
11
Lyr
2.3
Lyr Tzc
Lxc Zhu
Lxc Zhu Tzc Lyr git-clone
Lyr
Lyr
Lyr
Git git-pull git-pushgit-pull
git-push
git-pull git-push Lyr
M2GE
2.4 M2GE
Lyr
git-pull git-push
M2GE
12
2.5
Git Git
13
Git
CVSSVN
Git Git
3.1
master Git
Git local
local
git-branch
M2Doc
$ git branch
local
* master
Git
master
git-branch
local Git local git-checkout
local
$ git checkout local
3.2
local
master
git-merge local master
3.3 M2GE
Git
M2GE
1
M2GE
Lyr
M2GE
Lyr
$ git pull
$ git log
Lyr lyr
15
Lyr
3
M2GE master
lyr
$ git checkout
$ git merge lyr
$ git branch -d lyr
Lyr M2GE master
M2GE
git-pull
M2GE master
M2GE
1. git-pull
2.
Git
master
3. git-push master M2GE
Git M2GE
M2GE
git-clone
M2GE
3.4
Git M2GE
Git
Git
16