How do you guarantee that the commit will never be deleted?

Suppose I have a purely speculative commit that didn't work. I would like to save it, but I do not want to make a link (I do not want a branch or tag named "one-single-speculative-commit", and I certainly do not want 100 of them.) I can make the name of the branch "speculative" and put all the commits in it, but the commits are not completely connected with each other, so the connection between the commit and its parent is absurd. Essentially, I would like to be able to list a bunch of sha1 identifiers for commits that gc will not remove, but no links are needed for each of them. What a good way to do this? (I don't want gc.pruneExpire to be highly valuable, because I still want to trim things, I just want to keep a specific set of commits that would otherwise not be displayed.) In other words:

What is a good way to link to a collection of completely unrelated commits?

+3
source share
3 answers

The decision I decided to go with is relatively simple.

$ git update-ref refs / speculative / SHA1 SHA1

git -gc seems to respect ref and not remove it. Secure commits can be easily listed with:

$ git show-ref | grep refs / speculative

The only drawback that I have noticed so far is that git fsck --lost-found HEAD reports that they are hanging.

+3
source

( ). , , , , . , . , , , git, . - :

[alias]
    tags = !sh -c 'git tag | grep -v my_prefix'
+4

git stash, , ref, "stash", , git show-branch.

, . refs/remotes/graveyard/an-experiment, --branches, --all, .

+2

Source: https://habr.com/ru/post/1789254/


All Articles