git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [BUG?] After 'git checkout',  files deleted upstream are left in the working directory as untracked
@ 2020-10-10 16:43 Philippe Blain
  2020-10-11  6:58 ` Johannes Sixt
  2020-10-12 11:10 ` Johannes Schindelin
  0 siblings, 2 replies; 4+ messages in thread
From: Philippe Blain @ 2020-10-10 16:43 UTC (permalink / raw)
  To: Git mailing list

Hello all,

I've noticed a weird behaviour of 'git checkout' and I don't know if it's a bug.

I went back to an old clone which had an old feature branch ('stale-branch') 
checkout out, and its working directory and index matching HEAD 
('git status' is clean).
Then I did `git checkout other-branch`, where 'other branch' is a more 
recent feature branch, based on a more recent commit on 'master'.
After the checkout, `git status` reports untracked files. These are files that were 
deleted on 'master' between the commit on which 'stale-branch' was based (d9f6f3b619)
and the commit on which 'other-branch' is based (d4a392452e).

The thing is, I can't reproduce it on a fresh clone. If I could, this would be a reproducer:

```
$ git clone git@github.com:phil-blain/git.git && cd git
$ git checkout stale-branch
$ git checkout other-branch
$ git status # the following is what is shown in my old clone
On branch other-branch
Untracked files:
  (use "git add <file>..." to include in what will be committed)

	git-legacy-stash
	git-remote-testsvn
	t/helper/test-line-buffer
	t/helper/test-svn-fe

nothing added to commit but untracked files present (use "git add" to track)
```

I did not modify or delete any of these 4 files myself, neither in the commits 
on 'stale-branch' or in the commits on 'other-branch'. They were deleted by
other feature branches that were merged to 'master' between d9f6f3b619 and
d4a392452e.

This is not the first time that I've seen this happen, and I'd like to understand
if this is a bug, and why I can't reproduce it on a fresh clone (I'm guessing maybe
the index is at play here, but I'm not sure how to diagnose it)...

Thanks and cheers,

Philippe.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG?] After 'git checkout', files deleted upstream are left in the working directory as untracked
  2020-10-10 16:43 [BUG?] After 'git checkout', files deleted upstream are left in the working directory as untracked Philippe Blain
@ 2020-10-11  6:58 ` Johannes Sixt
  2020-10-11 16:19   ` Philippe Blain
  2020-10-12 11:10 ` Johannes Schindelin
  1 sibling, 1 reply; 4+ messages in thread
From: Johannes Sixt @ 2020-10-11  6:58 UTC (permalink / raw)
  To: Philippe Blain; +Cc: Git mailing list

Am 10.10.20 um 18:43 schrieb Philippe Blain:
> The thing is, I can't reproduce it on a fresh clone. If I could, this would be a reproducer:
> 
> ```
> $ git clone git@github.com:phil-blain/git.git && cd git
> $ git checkout stale-branch
> $ git checkout other-branch
> $ git status # the following is what is shown in my old clone
> On branch other-branch
> Untracked files:
>   (use "git add <file>..." to include in what will be committed)
> 
> 	git-legacy-stash
> 	git-remote-testsvn
> 	t/helper/test-line-buffer
> 	t/helper/test-svn-fe
> 
> nothing added to commit but untracked files present (use "git add" to track)
> ```

This is normal. These 4 files are build products and were never
committed files. They had been mentioned in .gitignore in the past, but
are not anymore.

Apparently, your old repository had these build products still lying
around. If you insert `make` in your instructions above after `git
checkout stale-branch`, you should be able to observe the same
un-cleanlyness in a new clone.

-- Hannes

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG?] After 'git checkout', files deleted upstream are left in the working directory as untracked
  2020-10-11  6:58 ` Johannes Sixt
@ 2020-10-11 16:19   ` Philippe Blain
  0 siblings, 0 replies; 4+ messages in thread
From: Philippe Blain @ 2020-10-11 16:19 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Git mailing list

Hi Johannes, 

> Le 11 oct. 2020 à 02:58, Johannes Sixt <j6t@kdbg.org> a écrit :
> 
> Am 10.10.20 um 18:43 schrieb Philippe Blain:
>> The thing is, I can't reproduce it on a fresh clone. If I could, this would be a reproducer:
>> 
>> ```
>> $ git clone git@github.com:phil-blain/git.git && cd git
>> $ git checkout stale-branch
>> $ git checkout other-branch
>> $ git status # the following is what is shown in my old clone
>> On branch other-branch
>> Untracked files:
>>  (use "git add <file>..." to include in what will be committed)
>> 
>> 	git-legacy-stash
>> 	git-remote-testsvn
>> 	t/helper/test-line-buffer
>> 	t/helper/test-svn-fe
>> 
>> nothing added to commit but untracked files present (use "git add" to track)
>> ```
> 
> This is normal. These 4 files are build products and were never
> committed files. They had been mentioned in .gitignore in the past, but
> are not anymore.

Oops, I should've checked that. Thanks for answering!

Philippe.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG?] After 'git checkout',  files deleted upstream are left in the working directory as untracked
  2020-10-10 16:43 [BUG?] After 'git checkout', files deleted upstream are left in the working directory as untracked Philippe Blain
  2020-10-11  6:58 ` Johannes Sixt
@ 2020-10-12 11:10 ` Johannes Schindelin
  1 sibling, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2020-10-12 11:10 UTC (permalink / raw)
  To: Philippe Blain; +Cc: Git mailing list

Hi Philippe,

On Sat, 10 Oct 2020, Philippe Blain wrote:

> $ git status # the following is what is shown in my old clone
> On branch other-branch
> Untracked files:
>   (use "git add <file>..." to include in what will be committed)
>
> 	git-legacy-stash
> 	git-remote-testsvn
> 	t/helper/test-line-buffer
> 	t/helper/test-svn-fe

These files were generated previously, but are no longer generated
(`legacy-stash` was retired in favor of the built-in `stash`,
`remote-testsvn` was dropped because it languished for long enough without
anybody picking it back up, and the test helpers were necessary to test
`test-svn`).

Since they are no longer generated, those build products are no longer
desired.

And you don't see them in a fresh clone because they were only compiled in
previous revisions.

So this works as expected.

What you will want to do is to run `git clean -dn` to see what `clean`
would remove, and once satisfied that it's all good, actually remove the
files using `git clean -df`.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-12 11:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-10 16:43 [BUG?] After 'git checkout', files deleted upstream are left in the working directory as untracked Philippe Blain
2020-10-11  6:58 ` Johannes Sixt
2020-10-11 16:19   ` Philippe Blain
2020-10-12 11:10 ` Johannes Schindelin

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git