简体   繁体   English

Git为什么新检查的远程分支更改了文件?

[英]Git why newly checked remote branch has changed files?

I am new to Git. 我是Git的新手。 I have checked new remote branch at my local. 我已经在本地检查了新的远程分支。 As I am checking out a new fresh branch from remote, I don't expect any local changes in the files of my repository. 当我从远程签出新分支时,我不希望存储库文件中发生任何本地更改。

But somehow few files show changes. 但是几乎没有文件显示更改。 I am using Git on Eclipse IDE. 我在Eclipse IDE上使用Git。

Why is so? 为什么会这样呢? Have I misunderstood the concept of new fresh branch checkout? 我是否误解了新的新鲜分支结帐的概念?

Update 更新资料

Based on comments by Tim Biegeleisen and Sajib Khan my understanding was wrong as it is expected behaviour when you check-out remote as a local branch any previous uncommitted changes in the working directory ( Repository ) will carry to the newly checked-out local branch. 基于Tim Biegeleisen和Sajib Khan的评论,我的理解是错误的,因为当您以本地分支远程签出时,这是预期的行为,工作目录(Repository)中任何先前未提交的更改都将携带到新签出的本地分支中。

Just to put in simple words let me explain with example 我只想简单地说一下

Think that your working in master branch and add some new file (Eg file1.txt and file2.txt). 认为您在master分支中工作,并添加了一些新文件(例如file1.txt和file2.txt)。 Now you don't stage or commit these 2 files then it will be shown as untracked files. 现在,您不暂存提交这2个文件,那么它将显示为未跟踪的文件。

Master Branch

Untracked  files
    file1.txt
    file2.txt

At this particular point of time you switch to another branch then the files which were untracked will be shown in the newly checkout branch. 在此特定时间点,您切换到另一个分支,然后未跟踪的文件将显示在新签出分支中。

To over come this problem you can go for the following 2 ways 要解决此问题,您可以采用以下两种方法

  1. Stash the files from master branch and then switch to another branch, now it wont show the untracked files of master in newly switched branches. 分支藏匿的文件,然后切换到另一个分支,现在它不会显示在新打开的分支主的未跟踪文件。 Stashing is nothing but saving the files and then reusing those at later point of time. 隐藏只是保存文件,然后在以后重新使用它们。

  2. commit amending 提交修改

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM