clearing stuff out of github isn’t hard, but it’s not trivial either. I really recommend getting a good book on git (the O’Reilly book is what I used) but I can walk you through the basics. I’m not saying this is the only way to do things, either - this is just the way I would handle it and other people might have different/better ways.
Your local git repository is basically a collection of commits (specific changes to specific files) and branches (collections of sequential set of commits). What you want to do is remove a bunch of commits from the master branch and then do git push --force to make the github copy of the repository match your local branch.
First, best development practice: don’t develop on your master branch. Checkout a new branch when you start developing or at least, before you commit a set of changes.
So here’s what I would do:
- from your current master branch, do “git checkout -b my_mod” - replace my_mod with whatever you want to name the branch. This will preserve a copy of your current branch in a new branch called my_mod.
- then do “git checkout master” to return your repository to your master branch.
- then do “get reset --hard origin/master” which will reset your current (ie, master) branch to match the commit history of github repository.[1] This will clear out all your changes.
- then do “git checkout my_mod” to return your repository to your my_mod branch.
- then do “git rebase -i master” which will open up an interactive rebase session. you’ll see all the commits in the my_mod branch, the most recent one at top, and ending just before the first shared commit with your master branch. There are instructions at the bottom, but you’ll just want to delete the lines for the commits you don’t want. Git will then reapply the remaining commits, starting from the top of the master branch.
- depending on what commits you removed, git may not be able to automatically apply the commits (ie, if you had commits a13, b24, and c35 that all touch the same lines in data/json/items.json and you don’t re-apply b24, then c35 will want to change a line that doesn’t match the result a13). Sorting out a broken rebase is even more complicated, but basically you want to use “git status” to see which files aren’t working, edit them until they’re right, and then use “git add” and “git rebase --continue” to effectively commit the change and continue.[2]
if all goes well, when the rebase is done, you’ll have a new my_mod branch that only contains the commits you want.
[1] if you’ve already pushed your bad master branch to github, you’ll need to git a clean copy from somewhere else. assuming you don’t already have Kevin’s repository as a remote, you’ll do “git remote add upstream https://github.com/CleverRaven/Cataclysm-DDA.git” then “git fetch upstream” then “git checkout -b upstream-master upstream/master” - which ends up creating a local branch called upstream-master which matches Kevin Granade’s github branch. Then do “git checkout master” to return to your local master branch, “git reset --hard upstream-master” to reset your master to match his, and “git push --force” to make your github verison match your local version.
[2] If you have access to git-gui or a similar smart commit tool, one trick I like to use when I have a messed up series of commits is to rebase -i against a reference point (like the master branch), squash/fixup all my commits into a single commit, open up git-gui, amend the last commit, remove all my changes from it so my working directory contains the net changes between the final result and the reference point, and then start adding the changes in logical chunks, each as a separate commit. But that’s a little advanced so please get a good book or something!