日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Git手册 - 分支远程同步

發布時間:2024/4/14 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Git手册 - 分支远程同步 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一)將本地分支連接到遠程分支,這里以GitHub上的同名倉庫(項目)為例

1)進入本地項目主分支

2)運行以下命令:

#git remote add origin git@github.com:path/repoName.git????????//將遠程倉庫命名為origin

3)當本地倉庫與遠程倉庫都僅有一個主分支時,運行以下命令:

#git push -u origin master????????//加參數-u,git不僅會將本地主分支所有內容推送到遠程主分支,還會自動將本地主分支與遠程主分支連接起來


注:

1)手動建立分支連接命令:

#git branch --set-upstream-to=origin/branchName branchName(local)

2)如果本地倉庫有多個分支,則需先手動建立對應分支連接,然后pull,最后再push來實現同步:

#git checkout branchName????????//默認master分支

#git branch --set-upstream-to=origin/branchName branchName(local)

#git pull origin branchName --allow-unrelated-histories

#git push

***Master以外其他分支:

#git checkout branchName??

#git push --set-upstream origin branchName????//將分支推送至遠程端,從而在遠程端創建同名的分支


二)克隆遠程倉庫

1)通過SSH

git clone ?git@github.com:TaoismLEE/Git.git

Notes 1:

????A. After modifying, use: "git push origin master" to push the modification.

????B. Can use: git remote -v to check the information about remote repository.

Notice 2:

If clone using SSH method, the data transfered between Git and Github will be encrypted with SSH key, so some settings should be made firstly in order to fetch the project from Github successfully:

Setting SSH key:

????A. In home folder, check whether the .ssh folder exists, if exists,then check whether there are "id_rsa" and "id_rsa.pub" files

????B. If the folder or the files not exist, then generate them by running following commands:

????#ssh-keygen -t rsa -C "email-address" //configured email of git

????C. Setting SSH Key in Github with the content of id_rsa.pub file //Open "Account settings" -> "SSH Keys"; then click "Add SSH Key";fill in "Title"; in the Key textarea, paste the content of id_rsa.pub file

2)通過HTTPS

git clone https://github.com/TaoismLEE/Git.git

or

git clone https://LoginUserName@github.com/TaoismLEE/Git.git

Notice:

If clone using HTTPS method, will need accout and password of remote Github when pushing modification to remote repository. OR running below command to store and remember the remote account information:

#git config --global credential.helper store

3)克隆后獲取非主分支

#git checkout -b dev(suggest to name the new local branch the same with the remote branch) origin/dev(other branch in remote repository)


三)協同工作

A. First, try to use "git push origin branch-name" to push our own modification

B. If conflict, then should use "git pull" to pull out the latest code

C. Fix conflicts manually and commit as a new version

D. Run "git push origin branch-name" again to push our code?

轉載于:https://blog.51cto.com/taoismli/1936951

總結

以上是生活随笔為你收集整理的Git手册 - 分支远程同步的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。