Re: working directory status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 17.11.19 um 21:33 schrieb Sivanandan Srilakshmanan:
> Reading git documentation, my understanding is that, if you needed to
> use "git worktree add" then it is recommended to keep your work tree
> (Working Dir) outside of your repository.
> My understanding, please correct me if I am wrong, is to have multiple
> worktree outside of the Git Repository.

That sounds reasonable. Note though that if you need N worktrees, then
you have one worktree with the (non-bare) repository, and N-1 worktrees
outside that repository.

> if you used "git clone" to setup your directory and your worktree is
> included in the same location as the Git Repository, then GIT_DIR is
> not required.

Yes.

> Please assist me to understand what I am doing incorrectly. The
> "output 1" below is incorrect because Local_Newfeature (working
> directory / worktree) is associated with the incorrect branch
> (Local_Kumfeature_branch)
> Local_Newfeature directory should be pointing to "Local_Newfeature_branch".
> 
> Output 2 is correct.
> 
> ====== Output 1 - incorrect =========================================
> C:\test\Local_Newfeature>git --work-tree=C:\test\Local_Newfeature status
> On branch Local_Kumfeature_branch
> Your branch is up to date with 'Lakshman/feature_branch'.

You observe this incorrect output because you have GIT_DIR set.
Obvously, Git looks at the branch that the HEAD of $GIT_DIR refers to.

Do not set GIT_DIR if you do not know what it is good for.

> ===== Output 2  - correct =============================================
> C:\test\Local_Newfeature>git branch
> * Local_Kumfeature_branch
>   Local_MyTest_branch
> + Local_Newfeature_branch
> + Local_SGSfeature_branch
>   Local_feature_branch

If Output 1 is incorrect, this is not correct, either: Note that
Local_Kumfeature_branch is marked as the branch for this directory, but
you intend it to be Local_Newfeature_branch, yet it is marked as living
in a different worktree.

Do not set GIT_DIR if you do not understand the consequences.

> C:\test\Local_Newfeature>git worktree list
> C:\GitRepo                (bare)
> C:/test/Local_Kumfeature  b0a097e [Local_Kumfeature_branch]
> C:/test/Local_Newfeature  b0a097e [Local_Newfeature_branch]
> C:/test/Local_SGSfeature  b0a097e [Local_SGSfeature_branch]

I do not know whether it is a sane use-case to have a bare repository
and separate worktrees.

Do not do that. Make a regular clone with a worktree and create
secondary worktrees from there.

-- Hannes



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux