Metasploit mailing list archives
Re: resetting git
From: Robin Wood <robin () digininja org>
Date: Sun, 16 Mar 2014 21:49:25 +0000
On 8 March 2014 14:30, Michael Schierl <schierlm () gmx de> wrote:
Hello Robin, Am 08.03.2014 09:24, schrieb Robin Wood:I've a fork of the git repo that I did following the official Metasploit instructions but I've not touched it for a couple of years and it is a mess, I've a couple of branches and some commits and I don't care about any of them. How do I reset my repo and get it back in sync with the current trunk?I assume you have a local repo already on your disk, which has two remotes pointing to your local github repo and to the upstream repo: $ git remote -v origin git () github com:schierlm/metasploit-framework.git (fetch) origin git () github com:schierlm/metasploit-framework.git (push) upstream git://github.com/rapid7/metasploit-framework.git (fetch) upstream git://github.com/rapid7/metasploit-framework.git (push) If not, use $ git remote remove ... $ git remote add ... to get to that state. Then fetch all current branches from upstream and origin, thereby marking old branches from upstream as deleted: $ git fetch upstream $ git fetch origin Remove the old remote branches from your local repo: $ git remote prune upstream $ git remote prune origin Reset your local branch "master" to upstream/master $ git checkout master $ git reset --hard upstream/master Stash away any local modifications, including any ignored or untracked files (I'm pretty sure you can also reset all of this somehow without stashing it first, but stash is the way I know, and you will want to clear your old stashes afterwards anyway), and then delete this stash and all others: $ git stash save --all $ git stash clear Delete all other local branches: $ git branch | grep -v master | xargs git branch -D Push your now very clean master branch to your github repo: $ git push origin +master (the + means overwrite even if it has modifications you don't have any more). You can delete your other remote branches on Github via the web interface or by listing them with "git branch -r" and then pushing them with a colon before the name $ git branch -r | grep "origin/" origin/master origin/oldbranch $ git push origin :oldbranch After you deleted all of your branches, fetch from upstream and prune again. $ git fetch origin $ git remote prune origin If you care about the old commits and stuff still using up local disk space, expire your reflog (which usually holds all repo states of the last few days in case you accidentally deleted a branch you still need) and gc the repo: $ git reflog expire --expire=all --all $ git gc
All seemed to work except I had to do these in the other order: $ git reset --hard upstream/master $ git checkout master Thanks Robin
Hope this helps, Michael
_______________________________________________ https://mail.metasploit.com/mailman/listinfo/framework
Current thread:
- resetting git Robin Wood (Mar 08)
- Re: resetting git Michael Schierl (Mar 08)
- Re: resetting git Robin Wood (Mar 08)
- Re: resetting git Robin Wood (Mar 16)
- Re: resetting git Robin Wood (Mar 16)
- Re: resetting git Tod Beardsley (Mar 16)
- Re: resetting git Robin Wood (Mar 17)
- Re: resetting git Michael Schierl (Mar 17)
- Re: resetting git Tod Beardsley (Mar 17)
- Re: resetting git Michael Schierl (Mar 17)
- Re: resetting git Michael Schierl (Mar 08)