第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

當(dāng)當(dāng)前分支上有未提交的更改時,簽出另一個分支

當(dāng)當(dāng)前分支上有未提交的更改時,簽出另一個分支

Git
胡說叔叔 2019-06-12 15:08:31
當(dāng)當(dāng)前分支上有未提交的更改時,簽出另一個分支大多數(shù)情況下,當(dāng)我嘗試簽出另一個現(xiàn)有分支時,Git不允許我在當(dāng)前分支上有一些未提交的更改。因此,我必須首先提交或保存這些更改。但是,偶爾Git允許我簽出另一個分支,而無需提交或保存這些更改,并且它會將這些更改攜帶到第一分支簽出。這里的規(guī)矩是什么?這些改變是階段性的還是非階段性的?把這些變化帶到另一個分支對我來說沒有任何意義,為什么git有時會允許它呢?也就是說,它在某些情況下有用嗎?
查看完整描述

3 回答

?
蝴蝶刀刀

TA貢獻(xiàn)1801條經(jīng)驗 獲得超8個贊

如果新分支包含與該特定更改文件的當(dāng)前分支不同的編輯,則在提交或存儲更改之前,它將不允許您切換分支。如果更改后的文件在兩個分支上都是相同的(即該文件的提交版本),那么您可以自由切換。

例子:

$ echo 'hello world' > file.txt
$ git add file.txt
$ git commit -m "adding file.txt"

$ git checkout -b experiment
$ echo 'goodbye world' >> file.txt
$ git add file.txt
$ git commit -m "added text"
     # experiment now contains changes that master doesn't have
     # any future changes to this file will keep you from changing branches
     # until the changes are stashed or committed

$ echo "and we're back" >> file.txt  # making additional changes
$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
    file.txt
Please, commit your changes or stash them before you can switch branches.
Aborting

這既適用于未跟蹤的文件,也適用于跟蹤的文件。下面是一個未跟蹤文件的示例。

例子:

$ git checkout -b experimental  # creates new branch 'experimental'
$ echo 'hello world' > file.txt
$ git add file.txt
$ git commit -m "added file.txt"

$ git checkout master # master does not have file.txt
$ echo 'goodbye world' > file.txt
$ git checkout experimental
error: The following untracked working tree files would be overwritten by checkout:
    file.txt
Please move or remove them before you can switch branches.
Aborting

一個很好的例子可以解釋為什么你想在做改變的時候在分支之間移動,如果你正在做一些關(guān)于主的實驗,想要提交它們,但是還沒有掌握。

$ echo 'experimental change' >> file.txt # change to existing tracked file
   # I want to save these, but not on master

$ git checkout -b experiment
M       file.txt
Switched to branch 'experiment'
$ git add file.txt
$ git commit -m "possible modification for file.txt"


查看完整回答
反對 回復(fù) 2019-06-12
  • 3 回答
  • 0 關(guān)注
  • 2122 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號