2017-02-23 18 views
0

有沒有辦法從另一個分支中引入項目,以便我的intelisense可以在不修改當前分支的情況下查看該分支的類?我不想合併,因爲這些類應該分開,我只想在不提交它們的情況下進行更改。從另一個分支使用git更改

回答

3

最簡單的事情就是合併沒有提交的分支。

git merge --no-commit thatotherbranch 

然後當你完成後,拋出更改。

git reset --hard HEAD 

如果你想這樣做來實驗,您可以創建一個臨時黨支部和合並的東西進去。然後在完成後刪除它(或者確定它是一個好主意並保留它)。

# Checkout the branch you want to work on 
git checkout mybranch 

# Create a new branch and check it out 
git checkout -b tempbranch 

# Merge in the branch with the changes you want 
git merge thatotherbranch 

...do whatever you like... 

# Switch back to the original branch 
git checkout mybranch 

# Delete the temp branch 
git branch -d tempbranch 
2

您可以在不提交結果的情況下執行合併。

1步:檢查出你想要合併到(我將使用主在這個例子中)

git checkout master 

第二步分支:合併以前的分支到主用--no提交標籤

git merge YOUR_BRANCH_NAME --no-commit 

這應該足夠了。如果您想提前查看更改,您可以在此時或合併之前始終運行差異。

合併-ff標記也許對你有用,但我還沒有使用它,所以不能評論某些。

當合並解析爲快進時,只更新分支指針,不創建合併提交。這是默認行爲。

git merge YOUR_BRANCH_NAME --no-commit --ff 

https://git-scm.com/docs/git-merge#git-merge---no-commit

https://git-scm.com/docs/git-diff

相關問題