一、获取远程库信息
1
2
3
|
$ git remote
-
v
origin https:
/
/
github.com
/
xxxxx
/
node.git (fetch)
origin https:
/
/
github.com
/
xxxxx
/
node.git (push)
|
二、克隆远程库
1
2
3
4
5
6
7
8
|
$ git clone https:
/
/
github.com
/
fuxinran
/
node.git
Cloning into
'node'
...
remote: Enumerating objects:
301
, done.
remote: Counting objects:
100
%
( 301 / 301 ), done.
remote: Compressing objects:
100
%
( 214 / 214 ), done.
remote: Total
301
(delta 83 ), reused 287 (delta 72 ), pack - reused 0
Receiving objects:
100
%
( 301 / 301 ), 2.28 MiB | 318.00 KiB / s, done.
Resolving deltas:
100
%
( 83 / 83 ), done.
|
三、提交代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
$ cd node
# 切换dev分支
$ git checkout
-
b dev
# 随便改点东西
$ vim README.md
# 提交到公共区
$ git add README.md
# 提交到版本库
$ git commit
-
m
'[* update the README.md file ]'
# 切换到master分支
$ git checkout master
# 合并代码
$ git merge dev
# 推送到远程服务器
$ git push orgin master
|
四、解决冲突
1
2
3
4
5
6
7
8
|
# 如果提交到远程库中出现代码冲突,将最新的代码拉下来
$ git pull
# 合并,解决冲突,提交远程仓库
$ git checkout master
$ git merge dev
$ git add README.md
$ git commit
-
m
'[* update README.md file ]'
$ git push orgin master
|