0

Let's say I cloned a repository. My local files are "clean", I will call it "Version A".

But now I need perform some config changes (connection strings, etc). That changes never need back to server. So I thought about create a new branch with my config changes ONLY. I will call it "Version B".

Finally, I will do some local work, bug fixes, etc. I will call it "Version C".

Now, I want send my changes to server. My idea is send to server "Version A" + "Version C", removing added the changes (or ignoring?) on "Version B".

I wonder if this is possible, and how I do it?

EDIT: If possible, tell me a ELI5 step by step...

Click Ok
  • 8,700
  • 18
  • 70
  • 106
  • Did you create separate branches for B and C? – mkrieger1 Jun 11 '18 at 19:45
  • @mkrieger1 Yes and No... I dont know what the best pratice here! This is my question! – Click Ok Jun 11 '18 at 19:50
  • You need to reorder the commits `A-B-C` -> `A-C-B`, then push `C`. If you don't know how to do that, see e.g. https://stackoverflow.com/questions/4981061/how-to-re-order-commits-in-git-non-interactively or https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History. – mkrieger1 Jun 11 '18 at 19:57

1 Answers1

1

You can use git rebase -i HEAD~2 to remove the Version B in your history.

After git rebase -i HEAD~2, your EDITOR will open. Just remove the FIRST LINE of the content, then save & exit EDITOR. Then your Version B will be removed.

Will Huang
  • 2,955
  • 2
  • 37
  • 90