簡體   English   中英

在新克隆的git repo中,我無法檢出到新分支

[英]In newly cloned git repo, I cannot checkout to a new branch

我只是克隆了Linux內核代碼,然后當我嘗試簽出到新分支時,我發現它由於本地更改而失敗。

我很困惑,為什么新克隆的代碼可能會有所謂的本地更改? 最后,我使用“ git checkout -f -b xxx ”強行檢出到新分支,以放棄本地更改,但是我仍然想知道是否有成功的檢出而不是強制的優雅方法?

$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
Cloning into 'linux-stable'...
remote: Counting objects: 5253622, done.
remote: Compressing objects: 100% (1189462/1189462), done.
remote: Total 5253622 (delta 4399195), reused 4796362 (delta 4030229)
Receiving objects: 100% (5253622/5253622), 1005.30 MiB | 576.00 KiB/s, done.
Resolving deltas: 100% (4399195/4399195), done.
Checking connectivity... done.
Checking out files: 100% (54401/54401), done.

$cd linux-stable

$ git checkout -b linux-4.2.y origin/linux-4.2.y
error: Your local changes to the following files would be overwritten by checkout:
        include/uapi/linux/netfilter/xt_RATEEST.h
        net/netfilter/xt_TCPMSS.c
Please, commit your changes or stash them before you can switch branches.
Aborting


$ git checkout -f -b linux-4.2.y origin/linux-4.2.y
Checking out files: 100% (28688/28688), done.
Branch linux-4.2.y set up to track remote branch linux-4.2.y from origin.
Switched to a new branch 'linux-4.2.y'

在我看來,一個無關的過程正在更改您的工作目錄。

為了避免這種復雜性,只需專門克隆到目標分支中即可:

git clone \
-b linux-4.2.y \
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM