GitLab本地、遠程更新已經fork的項目

單用IDEA沒法作到,必須配合使用Git命令行才能作到,並且是先從原做者項目更新本地庫,再從本地庫push到本身遠程fork項目,很是坑逼。html

1.到項目clone的根目錄右鍵Git Bash,先查看遠程源,通常只有你本身fork項目的源,沒有原做者的,須要添加遠程源:java


Administrator@admin-PC MINGW64 /e/git_projects/sunfield-microframe-service (master)
$ git remote -v
origin http://172.16.175.36:180/baigang/sunfield-microframe-service.git (fetch)
origin http://172.16.175.36:180/baigang/sunfield-microframe-service.git (push)git

Administrator@admin-PC MINGW64 /e/git_projects/sunfield-microframe-service (master)
$ git remote add upstream ssh://git@172.16.175.36:4422/jiaoma/sunfield-microframe-service.gitredis

Administrator@admin-PC MINGW64 /e/git_projects/sunfield-microframe-service (master)
$ git remote -v
origin http://172.16.175.36:180/baigang/sunfield-microframe-service.git (fetch)
origin http://172.16.175.36:180/baigang/sunfield-microframe-service.git (push)
upstream ssh://git@172.16.175.36:4422/jiaoma/sunfield-microframe-service.git (fetch)
upstream ssh://git@172.16.175.36:4422/jiaoma/sunfield-microframe-service.git (push)bash

Administrator@admin-PC MINGW64 /e/git_projects/sunfield-microframe-service (master)
$ git fetch upstream
The authenticity of host '[172.16.175.36]:4422 ([172.16.175.36]:4422)' can't beestablished.
ECDSA key fingerprint is SHA256:hFUMVxu5yYzhamirMDGSsvo3KbgbsVBQ3ZPTOBUIdqs.
Are you sure you want to continue connecting (yes/no)?
Host key verification failed.
fatal: Could not read from remote repository.服務器

Please make sure you have the correct access rights
and the repository exists.app

 

2.這裏添加了原做者ssh協議的源,由於沒有本機證書,沒法鏈接成功,因此須要改成添加http協議源,這裏本公司GitLab服務器須要帶上180端口ssh

Administrator@admin-PC MINGW64 /e/git_projects/sunfield-microframe-service (master)
$ git remote add upstream http://172.16.175.36:180/jiaoma/sunfield-microframe-service.git
fatal: remote upstream already exists.ide

Administrator@admin-PC MINGW64 /e/git_projects/sunfield-microframe-service (master)
$ git remote remove upstreamfetch

Administrator@admin-PC MINGW64 /e/git_projects/sunfield-microframe-service (master)
$ git remote add upstream http://172.16.175.36:180/jiaoma/sunfield-microframe-service.git

Administrator@admin-PC MINGW64 /e/git_projects/sunfield-microframe-service (master)
$ git remote -v
origin http://172.16.175.36:180/baigang/sunfield-microframe-service.git (fetch)
origin http://172.16.175.36:180/baigang/sunfield-microframe-service.git (push)
upstream http://172.16.175.36:180/jiaoma/sunfield-microframe-service.git(fetch)
upstream http://172.16.175.36:180/jiaoma/sunfield-microframe-service.git(push)

這裏須要先使用git remote remove命令移除此前錯誤添加的同名源(其實起別的名也能夠,fetch時從正確名字的源獲取便可)

 

3.從添加的原做者源fetch到本地倉庫,合併到本地倉庫:

Administrator@admin-PC MINGW64 /e/git_projects/sunfield-microframe-service (master)
$ git fetch upstream
remote: Counting objects: 103, done.
remote: Compressing objects: 100% (65/65), done.
remote: Total 103 (delta 24), reused 30 (delta 4)
Receiving objects: 100% (103/103), 12.50 KiB | 914.00 KiB/s, done.
Resolving deltas: 100% (24/24), completed with 6 local objects.
From http://172.16.175.36:180/jiaoma/sunfield-microframe-service
* [new branch] master -> upstream/master

Administrator@admin-PC MINGW64 /e/git_projects/sunfield-microframe-service (master)
$ git merge upstream/master
Updating 2970d82..27ca203
Fast-forward
pom.xml | 58 ++------
.../microframe/common/config/RedisConfig.java | 52 +++++++
.../microframe/common/redis/RedisBaseTemplate.java | 139 ++++++++++++++++++
.../microframe/common/redis/RedisHashTemplate.java | 157 +++++++++++++++++++++
.../microframe/common/redis/RedisListTemplate.java | 130 +++++++++++++++++
.../microframe/common/redis/RedisSetTemplate.java | 110 +++++++++++++++
.../microframe/provider/MUsersSqlProvider.java | 29 ++--
.../com/sunfield/microframe/rest/MUsersRest.java | 82 ++++++++++-
.../sunfield/microframe/service/MUsersService.java | 73 ++++++++++
src/main/resources/application.properties | 52 ++++---
10 files changed, 804 insertions(+), 78 deletions(-)
create mode 100644 src/main/java/com/sunfield/microframe/common/config/RedisConfig.java
create mode 100644 src/main/java/com/sunfield/microframe/common/redis/RedisBaseTemplate.java
create mode 100644 src/main/java/com/sunfield/microframe/common/redis/RedisHashTemplate.java
create mode 100644 src/main/java/com/sunfield/microframe/common/redis/RedisListTemplate.java
create mode 100644 src/main/java/com/sunfield/microframe/common/redis/RedisSetTemplate.java
create mode 100644 src/main/java/com/sunfield/microframe/service/MUsersService.java

 

4.把更新push到本身遠程fork庫:

Administrator@admin-PC MINGW64 /e/git_projects/sunfield-microframe-service (master)
$ git push
Enumerating objects: 119, done.
Counting objects: 100% (119/119), done.
Delta compression using up to 8 threads
Compressing objects: 100% (45/45), done.
Writing objects: 100% (103/103), 12.50 KiB | 2.50 MiB/s, done.
Total 103 (delta 24), reused 103 (delta 24)
remote: Resolving deltas: 100% (24/24), completed with 6 local objects.
To http://172.16.175.36:180/baigang/sunfield-microframe-service.git
2970d82..27ca203 master -> master

 

注意這裏應push到本身的遠程庫,而不是原做者的!

也可以使用命令:

git push origin master

這樣成功更新了本身本地庫、遠程fork庫,徹底不須要IDEA操做了。

 

參考博客:

https://blog.csdn.net/define_LIN/article/details/81044421

https://www.jianshu.com/p/83be892368d8

https://blog.csdn.net/qq_38835878/article/details/81195400

https://www.zhihu.com/question/20393785/answer/30725725

http://www.javashuo.com/article/p-zuwsmdwv-hp.html

切換分支和push到fork庫:

https://www.jianshu.com/p/29775d91f536

刪除遠程源:

http://www.javashuo.com/article/p-mmxbnpru-hm.html

相關文章
相關標籤/搜索