Questions tagged [git-squash]

git squash is the command used to rewrite git history before it is pushed to the remote.

GIT doesn't provide a modify history tool but provides measures to do so if the need arises. One can use git rebase in the interactive mode (git rebase -i) to achieve this with the parent of the last commit that you want to edit as the argument.

This is where git would present a text editor with the commits between this commit and the head listed in the reverse order. You can use "pick", "edit" or "squash" a commit.

squash specifically tells git to apply the commits in question and the commit before them in order and makes you to merge the commit messages.

This is a good way to keep the commit history on the remote cleaner while taking advantages of the version control to checkpoint your local code repo.

git rebase rewrites the history of the commits between parent mentioned above and head. Use with caution! It is not recommended to use this with the code that is already pushed to the remote.

216 questions
1
vote
2 answers

How to merge to another branch with only two commits and with one commit squashed?

I have created a branch for development and it has some useless commits. Now I want to merge the commits to the mainline branch. The only commits I want in the origin/master branch is the latest commit and another commit that squashes the first…
lezzago
  • 271
  • 1
  • 6
  • 15
1
vote
2 answers

Git Merge simple vs Squash. What is the purpose? How to track one commit per feature?

One thing I don't like with Git is the amount of commits. Don't get me wrong, it's a very convenient method of storing (safely) your work but in the long run there is too much granularity to search into. Let me describe the following scenario while…
Alex Sarafian
  • 634
  • 6
  • 17
1
vote
4 answers

Edit commit message after squashing

I want to implement featureX and I have committed it after writing it by git commit -m "featureX" After that I have done some changes and committed by git commit -m "yo1" squashed the commit by git rebase -i HEAD~2 again some changes and…
Mayank Jindal
  • 355
  • 5
  • 15
1
vote
2 answers

is git reset --hard necessary if merge fails?

I have the following bash script: git merge --squash -Xtheirs dev -m "squashing" && (./test/testsrc/shell/node-c.sh && echo "compiled successfully") || (git reset --hard; exit 1) I have two questions: If the merge fails, do I need to do a git…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
1
vote
1 answer

Git script to rebase and squash temporary commits

Of the few times I have squashed Git commits, it took some manual work to pick the previous commits I wanted to squash. Is there some way to so this automatically - my goal is to squash all previous commits that have not already been pushed to a…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
1
vote
1 answer

git merge --squash (branch) gives error

Currently I have a 1-user-model branch. From here, I then checked out and created a 1-user-model-squash branch. Then when I try to run git merge --squash 1-user-model, I get this error. fatal: You cannot combine --squash with --no-ff. I also…
kyangy
  • 65
  • 1
  • 9
1
vote
2 answers

Squashed commits onto feature branch and can't have a clean merge back to master now

Ok, so I've run into a bit of a trouble by squashing a bunch of commits, and want to know if there is a way to recover from this. Here is what happened, Here's where we started from: D (mybranch) / A--B--C (master) Work was done on both the…
Techtwaddle
  • 1,643
  • 1
  • 15
  • 11
1
vote
2 answers

Push master without feature branches

I've done quite a lot of search on this problem but didn't find an answer, though it seems to be a common scenario. Sorry if it is still a duplicate. I use Git to manage my Java source files. I'm the only developer. I created a 'remote' repository…
1
vote
1 answer

Using TortoiseGit to affect on a remote repository via rebase-squash

As the title suggests I am trying to squash the last two commits into one https://github.com/dvdvideo1234/Test and register that into the Github remote repo, though it only makes the changes locally, without committing them.. I am doing this via the…
1
vote
0 answers

Recover commit list after undoing an interactive rebase in git?

My situation: There are two remotes, origin and fork (the latter is owned by me). I checked out origin/devel, changed some code and committed like 5x to my local branch test. I pushed my commits to fork/test. Then I started an interactive rebase,…
CodeManX
  • 11,159
  • 5
  • 49
  • 70
1
vote
1 answer

Which factors contribute to size of git repo

I would like to know which factors contribute to the size of a git repo, Except the data of course. Does having a long history means a big repo? Does having many branches have some affect on it? Also how do you guys handle your commits? I read that…
Mukul
  • 141
  • 1
  • 11
1
vote
1 answer

Squash commit message in master branch

In Git after last push to remote repo I worked on master branch. I have 6 commits to push now. I want to squash these 6 into 1 commit message then do push. Any suggestion?
αƞjiβ
  • 3,056
  • 14
  • 58
  • 95
1
vote
3 answers

Combining non-linear commits into one commit (sausage making)

Consider the following git history: * 21f05f9 - Fifth commit * 0534049 - Fourth commit * 738ae0a - Third commit * 288ffd2 - Second commit * 2535dca - First commit How would I combine 21f05f9 738ae0a and 2535dca into one commit? I have tried git…
Fillip Peyton
  • 3,637
  • 2
  • 32
  • 60
0
votes
2 answers

best git practice to avoid squash

I have been using squash with the steps below and I find it really time consuming and error prone git rebase upstream/develop git merge-base mylocaldev upstream/develop (this will display a commit hash that can be used in the next step) git rebase…
user3277841
  • 339
  • 2
  • 6
  • 17
0
votes
1 answer

How to merge multiple commits onto another branch with multi (number of co developers) squashed commit?

Now there is a branch(branch1), three people P1 P2 P3 they develop together on branch1 with the comimit log P1 commit1 P2 commit2 P3 commit3 P3 commit4 P1 commit5 P2 commit6 ... P1 commit100 don't need to pay attention to the content of the…