Git: make local repo exactly like remote

I have been using slackrepo to maintain my own packages repository for Slackware 15.0. It’s an excellent tool, however, it has a limitation of how often you can sync with SlackBuilds.org. Usually this does not bother me, because I run an update once per week, after the Public www update (usually on Saturday). Every now and then, slackrepo will not see the updated SBo immediately, because it won’s sync.

So, I decided to manually make the local copy of SBo, exactly the same as the remote. I googled a bit and seems this does the trick:

First, navigate to the repo:

cd /var/lib/slackrepo/SBo/slackbuilds

Remove the branches which you have locally and are stale:

git fetch --prune origin

Remove all staged and unstaged changes, forget everything on the current local branch and make it exactly the same as origin/master. That’s pretty destructive, and I would think (more than) twice before using it on my own project. Also, adjust master or main.

git reset --hard origin/master

Remove unwanted files from your working directory.

git clean -f -d

Now, just do:

slackrepo update

As said above: I use this brutal approach just for the local copy of SlackBuilds.org, when working with slackrepo. I would not do it for a production project.


One Comment on “Git: make local repo exactly like remote”

  1. Anonymous says:

    This is indeed a brutal approach, because you probably want to have your own modification above the SBo repo.


Leave a comment