2017-07-06 104 views
0

因此,我研究了新功能,並意識到將本地提交到主分支會過於複雜。因此,我創建了一個新的分支如下:如何在不拉動的情況下推送新分支

$ git stash branch project_0.2 [email protected]{0} 

當然,問題是,當我嘗試新的分支推送到服務器,我得到:

$ git push origin master 
To https://svn.tudelft.nl/git/project.git 
! [rejected]  master -> master (non-fast-forward) 
error: failed to push some refs to 'https://svn.tudelft.nl/git/project.git' 
hint: Updates were rejected because a pushed branch tip is behind its remote 
hint: counterpart. Check out this branch and integrate the remote changes 
hint: (e.g. 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

我一直在尋找的互聯網和無處不在,我看到我應該git pull併合並更改。我試過這個(在我做備份之前),我得到:

$ git pull 
remote: Counting objects: 1105, done. 
remote: Compressing objects: 100% (304/304), done. 
remote: Total 725 (delta 501), reused 552 (delta 382) 
Receiving objects: 100% (725/725), 5.29 MiB | 0 bytes/s, done. 
Resolving deltas: 100% (501/501), completed with 165 local objects. 
From https://svn.3me.tudelft.nl/git/project 
    5d6516c..fd424b5 master  -> origin/master 
There is no tracking information for the current branch. 
Please specify which branch you want to merge with. 
See git-pull(1) for details. 

    git pull <remote> <branch> 

If you wish to set tracking information for this branch you can do so with: 

    git branch --set-upstream-to=origin/<branch> project_0.2 

我不知道我應該在這裏做什麼,所以我停了下來。而且,這些變化非常深刻,以致需要我永遠合併。我認爲可能有更智能的方法將分支推送到服務器。通過這種方式,我可以從團隊的其他成員那裏獲得幫助來修復代碼。這可能嗎?

+0

您在創建您的分支最離奇的方式。在任何情況下,典型的工作流程就是推新的分支,然後創建一個回到'master'的pull請求。太多的問題冒險給出答案。 –

+0

@TimBiegeleisen在閱讀[此答案](https://stackoverflow.com/a/30927991/611873)後,它似乎是一個很好的解決方案。 – aaragon

+0

如果你能告訴我們你想要用這個分支做什麼,也許可以給出答案或建議。 –

回答

0

創建新的分支首先使用

git checkout -b NewBranchName 

它會在您的本地機器上一個新的分支,現在按這個新的分支。

git push origin NewBranchName 
0

如果您想要將您的新功能與您在主分支中進行的操作隔離開來,則必須執行@UniCoder所說的操作。創建一個新的分支:

git branch NewBranchName 

以激活它:

git checkout -b NewBranchName 

做你的發展,添加你需要的對象,提交您對這個功能做的工作,然後創建新的分支作爲:

git push origin --set-upstream NewBranchName 

對於後來推動你只需把「混帳推起源」

+0

是的,我現在看到了,但我意識到太晚了,我需要一個新的分支。 – aaragon

+0

太糟糕了,我希望你不必做太多的重新工作。 –

相關問題