Recently I worked a long time on a redesign. I got so frustrated and went all the wrong way I wanted to revert back my latest version. This was way more complicated than I thought it should be, so for my future reference, here is the final fix.
INTERLUDE:
Use the github guide for answers to all things git...1.
Create a new branch, perhaps called 'Redesign'
git checkout -b Redesign
2.
Save current files of redesign and commit changes
git add .
git commit -m 'save redesign files'
3.
Move back to mastergit checkout master
4.
Revert to previous versiongit log
// get the previous version you want to make the current version on master
git reset --soft versionNumberCopiedFromAbove
// this sets the head of the master to the version you pasted above
// perhaps you can do git reset --hard not sure why one is better than the other
q
gets you out of git log
Show branchesgit branch
PS - The answer to this in the future is to always work in a new branch after making a commit. Every feature or addition should be on a new branch and merged to the master after it has been tested and agreed to by your team.
Normal branching and merging...Follow this excellent guide. It explains how a normal git process works in a live environment like at work. And here is
a visual interactive tool that is good to get your head wrapped around literally what git looks like in graphical representation.
example...
You have some work you have to do. You create and checkout a new branch and start working on it. Meanwhile, you get a request from your boss to fix a bug immediately. You have to checkout master, create a new branch for the bug fix and begin working on it. You add and commit your changes, then you checkout master again and merge the bug fix branch into master. Then you go back to work on your first branch by checking it out. you finish your work, add and commit your changes then checkout master again. you merge the branch you were working on into master.
delete previous branchYou should also delete previous branches that are complete.
merge conflictsIf you merge a branch to master and you or someone else has merged a branch they were working on into master and both of you happened to change the same section of code in the same file you will encounter a merge conflict. Git will not allow the merge and you must choose to either open up the file in your branch or the master and resolve the conflict. Git will mark what is conflicting with the branch you are in (master) on top and the branch that is conflicting below it. You can override changes by replacing the code with the proper code. After fixing the code and saving the file, git will ask you if you would like to merge these changes and resolve the conflict. If you agree git will add the changed file which you can see by running 'git status'. Then, you must commit the changes and everything will be up and running with the latest code.