Reset local changes when running the "repo sync" command?

2,443 views
Skip to first unread message

Peter Desjardins

unread,
Sep 30, 2016, 11:15:45 PM9/30/16
to Repo and Gerrit Discussion
I'm using repo to coordinate local clones of several repositories for documentation publishing automation. During publishing, the automation creates temporary files and makes small changes in the local clones. I want to make sure that I'm always starting with fresh clones of the repositories so that the resulting output isn't polluted by changes introduced by previous doc builds. I only need to read from my local clones, I'll never commit changes to them.

I want to run a command that will make sure that the local clones of the repositories I'm using match the latest commits on the target branches.

I tried 'repo sync -d' and 'repo forall -vc "git reset --hard"' after doing some googling, but I found that I still have temporary files in the local clone directories. When I run "git status" from the clone, it doesn't report any untracked files, but I can see the new files in the clone directory. I'm guessing that there's something about my clone having a detached HEAD that prevents it from resetting to a remote branch?

Before I add publishing steps that delete the entire local clone directories and ask "repo sync" to completely recreate them, is there a way to make the repo utility reset any local changes when it refreshes my local clones?

Thanks!

Peter

Magnus Bäck

unread,
Oct 5, 2016, 3:02:56 AM10/5/16
to Peter Desjardins, Repo and Gerrit Discussion
On Friday, September 30, 2016 at 17:40 CEST,
Peter Desjardins <peter.des...@gmail.com> wrote:

[...]

> I want to run a command that will make sure that the local clones of
> the repositories I'm using match the latest commits on the target
> branches.
> I tried 'repo sync -d' and 'repo forall -vc "git reset --hard"' after
> doing some googling, but I found that I still have temporary files in
> the local clone directories.

That's not surprising since neither of those commands remove untracked
files. You'll probably want to run "git clean -fdx" in each git.

> When I run "git status" from the clone, it doesn't report any
> untracked files, but I can see the new files in the clone directory.

Are they listed in a .gitignore file or .git/info/exclude?

> I'm guessing that there's something about my clone
> having a detached HEAD that prevents it from resetting to a remote
> branch?

No, I don't think that's related.

[...]

--
Magnus Bäck | Software Engineer, Firmware Platform Tools
magnu...@axis.com | Axis Communications
Reply all
Reply to author
Forward
0 new messages