forked from logzhan/NotesUESTC
34 lines
905 B
Markdown
34 lines
905 B
Markdown
|
1、查看远端仓库情况
|
|||
|
|
|||
|
```shell
|
|||
|
git remote -v
|
|||
|
# 样例输出如下:
|
|||
|
origin http://logzhan.ticp.io:30000/logzhan/management.git (fetch)
|
|||
|
origin http://logzhan.ticp.io:30000/logzhan/management.git (push)
|
|||
|
```
|
|||
|
|
|||
|
2、将仓库添加到本地
|
|||
|
执行完该命令,本地项目将同时关联到私有仓库与远程仓库地址。
|
|||
|
|
|||
|
```shell
|
|||
|
# 命令参数:upstream 表示远程仓库别名,类似于origin
|
|||
|
git remote add upstream 主库git地址
|
|||
|
```
|
|||
|
|
|||
|
3、从主仓库更新代码
|
|||
|
|
|||
|
```shell
|
|||
|
# 这句代码需要说明:这句话表示我们要从upstream的main分支拉去代码到当前分支!例如我们相把远端的A同步的本地的B
|
|||
|
# 需要先git checkout B 然后 git fetch upsteram A
|
|||
|
# 实际样例如下:
|
|||
|
git fetch upstream main
|
|||
|
```
|
|||
|
|
|||
|
4、推送到远程分支
|
|||
|
|
|||
|
```shell
|
|||
|
# 此处的master是一个样例,根据实际情况填写要合并的分支
|
|||
|
git merge upstream/master
|
|||
|
```
|
|||
|
|