git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Strange checkout with GIT_WORK_TREE
@ 2022-01-21 16:37 Lauri Rooden
  2022-01-21 22:09 ` brian m. carlson
  2022-01-21 23:09 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Lauri Rooden @ 2022-01-21 16:37 UTC (permalink / raw)
  To: git

Does the GIT_WORK_TREE get lost on the middle of process
or I am misunderstand the git checkout?

What did you do before the bug happened? (Steps to reproduce your issue)
- I wrote a shell script to reproduce

```git-test.sh
GIT_ROOT=$(mktemp -d)
GIT_COPY=$(mktemp -d)

echo "Create git repo with two commits: $GIT_ROOT"
cd $GIT_ROOT
git init
echo 1 > a.txt
echo 1 > b.txt
git add *.txt
git commit -m "Initial commit"
echo 2 > b.txt
git add b.txt
git commit -m "Second commit"

echo "Checkout to other work-tree: $GIT_COPY"
GIT_WORK_TREE=$GIT_COPY git checkout HEAD~1
git status

echo "ORIGIN $GIT_ROOT"
ls -la $GIT_ROOT
echo "COPY $GIT_COPY"
ls -la $GIT_COPY
```

What did you expect to happen? (Expected behavior)
- a.txt and b.txt checkouted to $GIT_COPY both with content `1`
- current folder unchanged

What happened instead? (Actual behavior)
- only b.txt checkouted to $GIT_COPY
- HEAD~1 checkouted in current folder but folder content remains HEAD
(modified:   b.txt)


[System Info]
git version:
git version 2.34.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 5.16.0-arch1-1 #1 SMP PREEMPT Mon, 10 Jan 2022 20:11:47
+0000 x86_64
compiler info: gnuc: 11.1
libc info: glibc: 2.33
$SHELL (typically, interactive shell): /usr/bin/bash


[Enabled Hooks]
prepare-commit-msg

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

end of thread, other threads:[~2022-01-22  9:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-21 16:37 Strange checkout with GIT_WORK_TREE Lauri Rooden
2022-01-21 22:09 ` brian m. carlson
2022-01-21 23:09 ` Junio C Hamano
2022-01-22  9:06   ` Lauri Rooden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).