git本地分支推送到遠程分支


1、創建的創建和初始化

創建git倉庫可以在遠端創建一個倉庫,
然后check到本地,在本地的文件里創建工程文件,然后提交

也可以將本地現有的工程和遠端的空倉庫關聯
本地創建了一個工程 iOSDemo
運行沒有錯誤,就可以提交到遠端了。

一般情況下,遠端倉庫創建成功之后會有以下提示

#Command line instructions

#Git global setup
git config --global user.name "wangjiangwei336"
git config --global user.email "ex_wljr_wangjiangwei@pingan.com.cn"

#Create a new repository
git clone http://gitlab.pab.com.cn/CARF/DUN-CLDS/dun-clds-open-front/ios/CarLoanAppR11.git
cd CarLoanAppR11
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

#Existing folder
cd existing_folder
git init
git remote add origin http://gitlab.pab.com.cn/CARF/DUN-CLDS/dun-clds-open-front/ios/CarLoanAppR11.git
git add .
git commit -m "Initial commit"
git push -u origin master

#Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin http://gitlab.pab.com.cn/CARF/DUN-CLDS/dun-clds-open-front/ios/CarLoanAppR11.git
git push -u origin --all
git push -u origin --tags

2、

git創建分支並切換到當前新創建的分支上
git checkout -b dev
開發完成后
git push origin dev

此時就將本地分支推送到遠程相應的分支上了
記得推到遠端之前先拉取最新代碼
git pull

然后如果本地有一個分支是你創建的dev0628 ,是不能直接提交代碼到遠程的,因為遠程並沒有一個叫 origin/dev0628 的分支,需要將本地dev0628 關聯到遠程 origin/dev0628
$git branch --set-upstream dev0628 origin/dev0628
fatal: the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead.

--set-upstream已經過時,需要用 新的命令 --set-upstream-to
$git branch --set-upstream-to origin/dev0628
Branch 'dev0628' set up to track remote branch 'dev0628' from 'origin'.

這樣本地分支就和遠程分支關聯起來了

[https://www.cnblogs.com/sugar-tomato/p/8295033.html]


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM