Metasploit mailing list archives
Re: resetting git
From: Robin Wood <robin () digininja org>
Date: Mon, 17 Mar 2014 07:28:13 +0000
On 16 Mar 2014 23:00, "Tod Beardsley" <todb () packetfu com> wrote:
TBH if you don't care about your local stuff you can just rm -rf
metasploit-framework locally, nuke your own origin, refork on GitHub, and reclone locally. That'll get you all the latest and none of the old and crusty branches.
I did think about doing that but thought there would be nice way to do it through git as I'm trying to learn how to use it properly. I'm still not 100% sure why things do what they do but it is making slightly more sense each time I learn something like this. Robin
On Sun, Mar 16, 2014 at 4:52 PM, Robin Wood <robin () digininja org> wrote:On 16 March 2014 21:49, Robin Wood <robin () digininja org> wrote: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 gcAll seemed to work except I had to do these in the other order: $ git reset --hard upstream/master $ git checkout masterShould have elaborated, when I did it your way it complained about a conflict that needed resolving before I could continue. Doing the reset seemed to fix that so the checkout could complete. RobinThanks RobinHope this helps, Michael_______________________________________________ https://mail.metasploit.com/mailman/listinfo/framework-- "Tod Beardsley" <todb () packetfu com> | 512-438-9165 | @todb Such coin, plz send: DC2N24MkGxyweDUMJ8kiYHdCm3feErX69a
_______________________________________________ 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)