I am a very basic git user; I basically only use the commands git add -a (to add files after modifying them) and then git commit -m "what I did" and then git push (to push it to my server).
Now I want to do something very drastic to my codebase. Something that might possibly not work — and I will have to revert back to where I was.
How do I do that? Do I create a “branch”? Or a tag? Or something else?
I am after a set of simple commands with simple explanations. also to then return to the original HEAD, or to then (maybe) merge the changes into HEAD (which won’t have changed)
Merc.
You need a branch.
This checks out your current branch (default name is ‘master’) as a new branch with the name you specify. Any commits you do now will be on the new branch. If you want to leave it and go back to where you were:
to go back to your new branch:
if you want to merge your branch into your main codebase:
–no-ff means you will see it branch out of master and then branch back in, allowing you to keep track of separate features.
To see what you’re doing, get a git source tree viewer of some sort e.g. source tree, gitk etc. Much easier to understand what the branches are doing if you can see them visually.
Update:
To check what would happen before merging, make a temporary branch in the same place as master and merge to there:
If you like it, merge it to master and it’ll be as if you did it on master in the first place:
If you don’t, just delete it:
-D means delete even if not merged to master. Use -d normally as you’ll get a warning if you try to delete unmerged stuff that you would lose.