0

I have 2 branches develop and squashed-develop. The commits in the develop branch are as follows:

b18aa3e - Fri Jan 11 15:08:55 2019 +0500
f47109f - Fri Jan 11 14:05:40 2019 +0500
0d7389f - Thu Jan 10 15:58:42 2019 +0500
98760df - Thu Jan 10 14:22:44 2019 +0500
4d8008d - Thu Jan 10 11:59:07 2019 +0500
1b63480 - Thu Jan 10 11:36:57 2019 +0500
d2ae644 - Thu Jan 10 11:26:48 2019 +0500
fd5ba74 - Thu Jan 10 11:11:35 2019 +0500
add2106 - Thu Jan 10 09:28:48 2019 +0500

Now i want to squash the commits that i get in the develop branch each day into a single commit and push them to the squashed-develop branch so that the work done each day is combined into a single commit in the squashed-develop branch.

So for example the commits of January 10 would be combined into a single commit and pushed to the squashed-develop branch. same would be the case with January 11 etc.

using interactive rebase mentioned here, i checked out a new branch from the develop branch, named it squashed-develop,and squashed all the initial commits of January 10th branch into a single commit

The problem is that i cant seem to figure out how will i be able to squash the commits of January 11 or January 12 in the develop branch and then push those squash commits to the squashed branch?

How can i achieve this? Thanks!

Hussain Ali Akbar
  • 1,585
  • 2
  • 16
  • 28
  • The question you cited certainly contains the information you would need to figure it out. What have you tried, and what is your exact question? – Tim Biegeleisen Jan 11 '19 at 10:24
  • do you still want to retain all those many commits in the develop branch? because you'll lose them if you use a git rebase – BenKoshy Jan 11 '19 at 10:27
  • Let's assume you are on the `develop` branch. Let's say `HEAD` is currently at commit `ABCD`. Run `git rebase -i squashed-develop` and squash those commits. checkout the squashed-develop branch by running `git checkout squashed-develop` and then `git reset --hard develop`. Now the squashed-develop and the develop branch are pointing at the same commit. Checkout the develop branch `git checkout develop` and continue working on it, adding incremental commits tomorrow, and simply follow the instructions from the beginning. That way, you'll have those incremental commits + the squashed commits. – BenKoshy Jan 11 '19 at 10:35
  • @TimBiegeleisen, i could not put together the complete strategy to achieve this - hence the question and the reference. And all i have been able to do yet is check out a new branch from develop named squashed-develop and squash all commits inside it using interactive rebase. I could not figure out how to proceed further than this. What else do you not understand about the question as i am happy to explain it further! – Hussain Ali Akbar Jan 11 '19 at 10:41
  • You would be better off [reading this helpful blog post](https://robots.thoughtbot.com/git-interactive-rebase-squash-amend-rewriting-history) than to wait for someone to give you an answer here. – Tim Biegeleisen Jan 11 '19 at 10:42
  • yes @BKSpurgeon, i want to retain the commits in the develop branch. As for the strategy you mentioned, i thought of that too but the problem is that I cannot push the squashed commit back into the develop branch. Thats the thing that i'll resort to in case I cant find a solution to the current problem. – Hussain Ali Akbar Jan 11 '19 at 10:44
  • @TimBiegeleisen, thanks. I'll take a look into it. – Hussain Ali Akbar Jan 11 '19 at 10:44

0 Answers0