Ports tree have been migrated to git

Dimitry Andric dim at FreeBSD.org
Sun May 2 10:48:10 UTC 2021


On 2 May 2021, at 08:48, Kurt Jaeger <pi at freebsd.org> wrote:
> 
>>> # git checkout origin/main
>>> error: The following untracked working tree files would be overwritten by checkout:
>>>       multimedia/transcode/files/patch-import_demux__pass.c
>>>       multimedia/transcode/files/patch-import_extract__ac3.c
>>>       multimedia/transcode/files/patch-import_extract__mp3.c
>>>       multimedia/transcode/files/patch-import_extract__pcm.c
>>> [...]
>>> Please move or remove them before you switch branches.
>>> [...]
>> 
>> Ah yes, I was assuming that you were starting with a clean tree. In this
>> case you could have used "git stash" to stash away the changes, and get
>> them back later.
> 
> # git stash
> No local changes to save

Yes, this is because you manually got rid of those files. Normally, if
you have several outstanding changes in your working copy, you use "git
stash" (the full command is actually "git stash push") to stash away
those changes. Then you can do stuff like pulling, merging or whatever
you like, and finally you do a "git stash pop" to get your outstanding
changes back.

For instance, if you are working on some patch, and somebody in your
team says "I've pushed a fix, please pull", you would typically do:

git stash
git pull
<fix up any conflicts if they occur>
git stash pop


>>> Ok, I deleted those, but then
>>> 
>>> git show
>>> 
>>> shows me details of
> [...]
>>> $ git branch -d main
>>> error: Cannot delete branch 'main' checked out at '/pou/ports/default'
>>> $ git branch -D main
>>> error: Cannot delete branch 'main' checked out at '/pou/ports/default'
>> 
>> That means you are using worktrees, so indeed then you cannot delete the
>> main branch, as that other location is using it.
> 
> I was not aware that I use a worktree, but this is the list of worktrees
> in use:
> 
> # git worktree list
> /pou/ports/default  7e1519526 [main]

Ah, I think that what happened is that your initial "git checkout
origin/main" failed because of your untracked files, and then you did
not repeat the "git checkout origin/main" after getting rid of those
files?

In that case, the local 'main' branch was still checked out in your
one-and-only working tree, which is why it cannot be deleted, at that
point.

(Unfortunately it is not easy to give git "recipes" that work in any and
all situations, as local changes can influence what git will do. Here,
I was assuming you had a clean working area, which was not the case.)


> $ git show
> #ommit dc5a6492de7a0b3e79d48a02f4678c5af4467e40 (HEAD -> main, origin/main, origin/HEAD)
> [...]
> Again I expected that 'git show' does not display anything, as
> I should be in the state of a pristine repo without anything
> to show ?

"git show" without any further arguments does not show the current
changes in your working tree, but the contents of HEAD. Usually that is
the last commit on the branch that you have checked out.

If you want to see an overview of changes you have done in your current
working tree, use "git status" instead.

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 223 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.freebsd.org/pipermail/freebsd-git/attachments/20210502/5c48fc3f/attachment.sig>


More information about the freebsd-git mailing list