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
8
votes
1 answer

git: how to squash multiple merge commits

I'm working on a git repository which I forked from an upstream. There was a feature I wanted to implement and I created a new branch uiTests and did changes there and made a pull request. The PR was there for a while and in the meantime there were…
Padmal
  • 458
  • 5
  • 15
8
votes
1 answer

Squashing commits after they are pushed

Imagine a git repository with the following commits: Fixed issue 3 123eabc Fixed issue 2 (part 2) fa23b79 Fixed issue 2 (part 1) 7bea5cc Fixed issue 1 0d229f4 These are all pushed to remote master already. Is…
Merik
  • 2,767
  • 6
  • 25
  • 41
7
votes
1 answer

Git rebase feature branch messes up commits in pull request to develop/master branch

I have the following scenario: Master-branch: what is in production, can contain hotfixes Develop-branch: the branch my developers are using to create pull requests to feature-branches: the branch we create for the feature the developer is…
Serafijn
  • 87
  • 7
7
votes
4 answers

How to tell if git branch has been fully merged after squash

When merging branches with --squash, git does no longer seem to be able to determine whether a branch has been fully merged. How can I quickly check this with existing git commands? To reproduce, create a new git repository: $ mkdir tmp $ cd tmp $…
digory doo
  • 1,978
  • 2
  • 23
  • 37
7
votes
1 answer

Does GitHub retain commit history for squash merged PRs indefinitely?

Our team is deciding on what merge strategy to use in our repo. We're looking at squash merges for the ability to have a clean commit history. However, we want to be able to review intermediate changes if we want more detail on a particular commit -…
7
votes
3 answers

Git merge with --squash while keeping log of every commit

Initial scenario: A (master) \ B - C - D (development) What I want after merge --squash: A - E (master/development) \ / B - C - D On branch master, git log would be commit E Squashed commit of the following: commit D …
Zizheng Wu
  • 646
  • 1
  • 12
  • 21
6
votes
1 answer

Branching from a feature branch and reconciling commits after main squash merge

I have the following situation: I've worked on a feature branch (called work1) to which I have an outstanding PR. While I wait for the PR to be approved, I want to start working on a new feature branch (called work2). The problem is that my…
Leonardo
  • 1,533
  • 17
  • 28
6
votes
2 answers

How to automatically rebase all children branches onto master after squashing and merging the parent branch?

Building on this question, I have a workflow where I'm constantly making PRs on top of PRs to make it easier for others to review my work. Goal is to have smaller PR sizes. So I often end up with situations like the following: …
giwofe5619
  • 63
  • 4
6
votes
0 answers

Squash commit option is disabled on visual studio community

I created a simple folder with a file and performed few commits for practicing squash. I selected two commits and right click. However, the squash commit option is disabled. Where am I going wrong?
Aditya Bokade
  • 1,708
  • 1
  • 28
  • 45
6
votes
2 answers

How fix my git branches after squashing is master behind dev

I have created 2 commits to remote dev branch. That I squashed and merge into remote master branch. Now when I want to continue with working on dev branch - I don't know how can I correctly "repair" my branches - because after creating new pull…
Jenan
  • 3,408
  • 13
  • 62
  • 105
6
votes
3 answers

How to sync up your git dev branch after you've merged+squashed a PR to master, in GitHub?

So GitHub has the ability to merge+squash commits for a PR. We follow the process of PR'ing code from dev -> master. Previously, I've been just 'merging' the PR's but that generates a new commit which says: "Merge Pull Request #1 from foo/bar". :(…
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647
6
votes
2 answers

Intellij "before commit" options meaning

I cannot find the documentation about the several options (checkboxes) that are visible when commiting. I'm looking for an option to squash all commits from the IDE, and I'm wondering if one of these options couldn't help me to do that. Is there…
Vadorequest
  • 16,593
  • 24
  • 118
  • 215
6
votes
2 answers

Compare branches after git merge with --squash

I have a parent branch A with a child branch B. In branch B i have two separate commits. I merged branch B in A with squash like this git merge --squash B When i compare branch A with branch B: git log A..B It shows the both the commits from…
Arif
  • 1,369
  • 14
  • 39
5
votes
1 answer

Still compare committed difference after squash merging

I have merged a develop branch into main branch using squash merge. Let's say there are commit A, B, C merged into main from develop. The changes are successfully merged. I can see the squash commit on the main branch and the files are…
WenliL
  • 419
  • 2
  • 14
5
votes
1 answer

Avoiding conflicts in git when merging a squashed commit from main into feature branch

Consider the following practice: A developer branches from main and creates as many commits as needed in a feature branch Once the feature is completed, all commits are squashed and merged into the main branch (for instance, think of a GitHub's…
1 2
3
14 15