-
Notifications
You must be signed in to change notification settings - Fork 0
/
leangit.txt
136 lines (67 loc) · 2.36 KB
/
leangit.txt
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"
创建一个git目录
在git目录下
git init
git add readme.txt
git commit -m "add 3 files."
git status
git log
git log --pretty=oneline
git reset --hard HEAD^
要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本。
git reflog
git remote add origin [email protected]:oldxing/learngit.git
第一次
git push -u origin master
以后
git push origin master
gitskills
https://github.com/oldxing/gitskills.git
git clone https://github.com/oldxing/gitskills.git
或者
git clone [email protected]:oldxing/gitskills.git
git checkout -b dev
相当于以下两条命令:
git branch dev
git checkout dev
git branch
git add readme.txt
git commit -m "branch test"
git checkout master
合并
git merge dev
保留痕迹的合并
git merge --no-ff -m "merged bug fix 101" issue-101
git branch -d dev
查看分支:git branch
创建分支:git branch <name>
切换分支:git checkout <name>
创建+切换分支:git checkout -b <name>
合并某分支到当前分支:git merge <name>
删除分支:git branch -d <name>
可以把当前工作现场“储藏”起来,等以后恢复现场后继续工作:
$ git stash
工作现场存到哪去了?用git stash list命令看看:
$ git stash list
一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除;
另一种方式是用git stash pop,恢复的同时把stash内容也删了:
==================================================================
Quick setup — if you’ve done this kind of thing before
or
HTTPS
SSH
https://github.com/oldxing/learngit.git
Get started by creating a new file or uploading an existing file. We recommend every repository include a README, LICENSE, and .gitignore.
…or create a new repository on the command line
echo "# learngit" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/oldxing/learngit.git
git push -u origin master
…or push an existing repository from the command line
git remote add origin https://github.com/oldxing/learngit.git
git push -u origin master
…or import code from another repository
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.