gpt4 book ai didi

git - 如何删除 git 中的选择性存储?

转载 作者:行者123 更新时间:2023-12-02 07:17:14 25 4
gpt4 key购买 nike

我有存储列表,想有选择地删除其中一些。

以我的示例为例,我想删除 stash@{1}、stash@{3}、stash@{4}、stash@6}

$git stash list

stash@{1}: Tests On branch1-om: Test for #8
stash@{2}: WIP On branch1-om: WIP for #12
stash@{3}: Temp on branch1-om: 0a447303 Add Unit Tests for the HttpClient
stash@{4}: To delete stash: 233abc813c fix
stash@{5}: WIP on branchn-test-om: 4a42e4 WIP: Commit
stash@{6}: On branch-test-om: projects deleted/modified when rebuilt
stash@{7}: My configurations: Apply my local dev configurations

我当前的步骤非常重复:

$git stash drop stash@{1}

$git stash list

stash@{1}: WIP On branch1-om: WIP for #12
stash@{2}: Temp on branch1-om: 0a447303 Add Unit Tests for the HttpClient
stash@{3}: To delete stash: 233abc813c fix
stash@{4}: WIP on branchn-test-om: 4a42e4 WIP: Commit
stash@{5}: On branch-test-om: projects deleted/modified when rebuilt
stash@{6}: My configurations: Apply my local dev configurations

$git stash drop stash@{2}

$git stash list

stash@{1}: WIP On branch1-om: WIP for #12
stash@{2}: To delete stash: 233abc813c fix
stash@{3}: WIP on branchn-test-om: 4a42e4 WIP: Commit
stash@{4}: On branch-test-om: projects deleted/modified when rebuilt
stash@{5}: My configurations: Apply my local dev configurations

$git stash drop stash@{2}

$git stash list

stash@{1}: WIP On branch1-om: WIP for #12
stash@{2}: WIP on branchn-test-om: 4a42e4 WIP: Commit
stash@{3}: On branch-test-om: projects deleted/modified when rebuilt
stash@{4}: My configurations: Apply my local dev configurations

$git stash drop stash@{3}

$git stash list

stash@{1}: WIP On branch1-om: WIP for #12
stash@{2}: WIP on branchn-test-om: 4a42e4 WIP: Commit
stash@{4}: My configurations: Apply my local dev configurations

最佳答案

问题是从顶部移除 stash 会重新编号。但是因为您可以在任何位置删除它们,所以您不需要表现得好像 stashes 只有类似堆栈的访问权限。

从最远的地方放下它们,以保持数字完整:

for N in 6 4 3 1; do git stash drop stash@\{$N}; done

关于git - 如何删除 git 中的选择性存储?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59290400/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com