3
Git更新远程仓库代码到本地
source link: https://blog.51cto.com/u_14068620/5705669
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
1、查看远程分支
[root@linux-node1 opslinux]# git remote -v
origin https://github.com/Lancger/opslinux.git (fetch)
origin https://github.com/Lancger/opslinux.git (push)
2、从远程获取最新版本到本地
使用如下命令可以在本地新建一个temp分支,并将远程origin仓库的master分支代码下载到本地temp分支
[root@linux-node1 opslinux]# git fetch origin master:temp
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 15 (delta 10), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (15/15), done.
From https://github.com/Lancger/opslinux
* [new branch] master -> temp
3、比较本地仓库与下载的temp分支
[root@linux-node1 opslinux]# git diff temp
diff --git a/index.md b/index.md
deleted file mode 100644
index ff6da49..0000000
--- a/index.md
+++ /dev/null
@@ -1,109 +0,0 @@
...........
4、合并temp分支到本地的master分支
[root@linux-node1 opslinux]# git merge temp
对比区别之后,如果觉得没有问题,可以使用如下命令进行代码合并:
[root@linux-node1 opslinux]# git merge temp
Already up-to-date.
5、删除temp分支
[root@linux-node1 opslinux]# git branch -d temp
Deleted branch temp (was 7eb97aa).
如果该分支的代码之前没有merge到本地,那么删除该分支会报错,可以使用git branch -D temp强制删除该分支。
6、然后再执行
git add *
git commit -m "项目更新"
git push origin master
解决了冲突合并了,才可以提交上来
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK