-1

I have commits like

12345
12346
12347

I want to get back tgo 12345 and work on this I will add new commits 23456, 23457, 23458 etc

then I may need to get 12345, 12346, 12347 and 23456, 23457, 23458 all together

Is this possible, what should be my steps to achieve this?

Prafulla Kumar Sahu
  • 9,321
  • 11
  • 68
  • 105
  • What does "get all together" mean here? – Tim Biegeleisen Feb 12 '19 at 09:02
  • @TimBiegeleisen I want all the commits the current one's and old one, but for now I want to push only `12345` and `23456, 23457, 23458` and not `12346`, `12347` latter I will decide if I will push `12346` and `12347` or not. – Prafulla Kumar Sahu Feb 12 '19 at 09:06
  • Possible duplicate of [How to revert a Git repository to a previous commit](https://stackoverflow.com/questions/4114095/how-to-revert-a-git-repository-to-a-previous-commit) – Liam May 23 '19 at 11:08

2 Answers2

2

You have to make a new branch starting from the commit 1234

git checkout -b newBranchName <SHA of the starting commit>

Then work on this branch and make your commits [23456, 23457, 23458 ....] and after that you can merge the old and new branches to get the rest of the commits [12346, 12347..] as follows

git merge <Base branch name>

Now all of your work is on the new branch

E.Omar
  • 109
  • 1
  • 11
1

First try creating a new branch from the 12345 commit:

git checkout -b new_branch 12345

Then make your new commits 23456, 23457, 23458 on top of this branch. So, your two branches now look like this:

old_branch: 12345 -- 12346 -- 12347
                  \
new_branch:          23456 -- 23457 -- 23458

If you want to later bring one set of commits from one branch into the other, you may try merging or rebasing.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360