如何使用 repo 放弃更改

发布于 2024-10-17 12:00:24 字数 154 浏览 3 评论 0原文

repo status 显示了很多不需要的更改。

如果我输入每个项目并使用 git reset --hard ,它将会重复。

有没有办法使用 repo 重置所有更改,例如 repo reset --hard

repo status shows me a lot of un-wanted changes.

It would be duplicated if I enter every project and use git reset --hard.

Is there a way to reset all the changes using repo, something like repo reset --hard?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

请止步禁区 2024-10-24 12:00:24

这是我用于此类事情的命令,非常有用

repo forall -vc "git reset --hard"

这里的一切意味着什么?

repo forall将为所有存储库执行。

-v 很详细,因此它将打印命令的输出

-c "COMMAND TO EXECUTE" 是您想要的实际命令

This is the command I use for this kind of things, very useful

repo forall -vc "git reset --hard"

What everything mean here ?

the repo forall will execute for all repos.

the -v is verbose, so it will print the output of the command

the -c "COMMAND TO EXECUTE" is the actual command you want

谁的新欢旧爱 2024-10-24 12:00:24

如果需要将工作文件夹恢复到没有本地修改且没有未跟踪文件的干净状态(即存储库状态不显示任何内容),我发现这两种方法对于存储库同步和删除/修改的文件很有用

repo forall -c 'git reset --hard ; git clean -fdx' 

,或者

rm -rf * ; repo sync -l
// note that .repo is preserved after that

请注意,这是不等同于初始化新的本地存储库并同步(例如保留存储)

如果您不确定发生了什么,请阅读完整的帖子 存储库同步和删除/修改的文件

If there is a need to revert working folder to the clean state where you don't have local modifications and no untracked files (i.e. where repo status shows nothing), I found these two approaches useful on repo sync and deleted/modified files

repo forall -c 'git reset --hard ; git clean -fdx' 

or

rm -rf * ; repo sync -l
// note that .repo is preserved after that

Note, that this is not equivalent to initializing a new local repo and syncing (e.g. stash is preserved)

If you are not sure what is going on, please read the full thread repo sync and deleted/modified files

梦回梦里 2024-10-24 12:00:24

工作命令是:

repo forall -vc "git reset --hard"

命令和选项说明

  • forall

在每个项目中执行给定的 shell 命令

(可与 forall 命令一起使用)

-c:要执行的命令和参数。该命令通过 /bin/sh 进行评估,其后的任何参数都作为 shell 传递
位置参数。

-p:在指定命令的输出之前显示项目标题。这是通过将管道绑定到命令的 stdin、stdout 和
sterr 流,并将所有输出通过管道传输到连续流中
显示在单个寻呼机会话中。

-v:显示命令写入 stderr 的消息。

有关更多信息,请参阅repo 文档

The working command is :

repo forall -vc "git reset --hard"

The command and options description

  • forall

Executes the given shell command in each project

Options (that can be used with the forall command)

-c: command and arguments to execute. The command is evaluated through /bin/sh and any arguments after it are passed through as shell
positional parameters.

-p: show project headers before output of the specified command. This is achieved by binding pipes to the command's stdin, stdout, and
sterr streams, and piping all output into a continuous stream that is
displayed in a single pager session.

-v: show messages the command writes to stderr.

For more information please refer the repo document

完美的未来在梦里 2024-10-24 12:00:24

我使用带有以下语法的 repo forall 命令,它可以帮助我重置跟踪文件。

repo forall -p -c 'git checkout -f foo'

其中 foo 应替换为合法的分支名称。

I use the repo forall command with the below syntax and it helps me to reset the tracking files.

repo forall -p -c 'git checkout -f foo'

where foo should be replaced with a legitimate branch name.

云归处 2024-10-24 12:00:24

repo forall 没有覆盖所有 git 树

#!/bin/bash
for gitdir in $(find . -type d -name .git -prune); do
    pushd $(dirname $gitdir)
    git reset --hard
    popd
done

repo forall does not cover all of the git tree

#!/bin/bash
for gitdir in $(find . -type d -name .git -prune); do
    pushd $(dirname $gitdir)
    git reset --hard
    popd
done
喜你已久 2024-10-24 12:00:24

存储库工具现在有几个选项,作为存储库同步操作的一部分,它们还可以更快地清理森林。

  --force-checkout      force checkout even if it results in throwing away
                        uncommitted modifications. WARNING: this may cause
                        loss of data
  --force-remove-dirty  force remove projects with uncommitted modifications
                        if projects no longer exist in the manifest. WARNING:
                        this may cause loss of data

The repo tool now has a couple options that can also clean up your forest more quickly as part of the repo sync operation.

  --force-checkout      force checkout even if it results in throwing away
                        uncommitted modifications. WARNING: this may cause
                        loss of data
  --force-remove-dirty  force remove projects with uncommitted modifications
                        if projects no longer exist in the manifest. WARNING:
                        this may cause loss of data
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文