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
0
votes
2 answers

Git + IntelliJ - how to make files appear again in commit-tab

IntelliJ has this nice features with a commit-tab in their IDE, which allows you to see all the changes in all files, and also has the revert-button and a lot of other useful functions that I like. The thing is that those files are only shown there…
klabbaparn
  • 157
  • 3
  • 9
0
votes
2 answers

Commit Author Not showing recent commiter name when doing Git Squash

I have a branch and few commits done by some other person. I committed few more changes to the same branch. Now i am squashing all commits to one single commit using below commands. git rebase -i HEAD~2 From the displayed commit list changed…
Deadpool_er
  • 215
  • 4
  • 20
0
votes
0 answers

Change default Squash And Merge commit message algorithm

I want to write CI/CD script, which will change the default generated Squash And Merge commit into the convention my team uses. Is it possible to change it in CI/CD level, can I get commit messages in the script and generate a new commit message?…
0
votes
0 answers

Merge commit from main branch to release

I have two main separate branch Master and release. My two PR(pull request) merged to Master branch called. featureA and featureB and deleted. Also many other feature branch merged to Master by different people. Now, I want to create new PR/branch…
ketan
  • 19,129
  • 42
  • 60
  • 98
0
votes
1 answer

How to squash commit to last commit? - problem with order

In the company I work for, we use Gerrit (unfortunately) and I need to flatten non-pushed commits into one comit. When I check the commit list in InteliJ, I see: ed4ad5ffd67504a37a43ae6bf66d0f31456e4e81 (HEAD -> develop) [CSTC-1096] ESlint…
JanuszFrontEnd'u
  • 451
  • 6
  • 14
0
votes
1 answer

Squash all commits on a branch you have pulled

I was working on a feature branch to which I had pushed some commits. I had an issue with my machine and had to do a fresh install and pull the remote branch to continue working on the issue. the problem comes in when I try to squash all the…
mutisya
  • 1
  • 2
0
votes
0 answers

Git how to rebase commits on master after pulling?

I checked out a branch: git checkout -b myBranch Made some commits: git commit -m 'msg' git commit -m 'msg2' Then I pulled from master. Now I have many staged files in which I did no work. How can I squash all the changes from master and move my…
yalpsid eman
  • 3,064
  • 6
  • 45
  • 71
0
votes
2 answers

how to squash last two commits into a merge commit

this is my git log history, I want to squash my last two commits into "merge release into feature" commit (which is a merge commit) I tried with git rebase -i HEAD~3 and keep getting this error "cannot squash without a previous commit error" commit…
Sam
  • 6,215
  • 9
  • 71
  • 90
0
votes
1 answer

is it possible to squash commits via Github API?

I've successfully implemented automatic file creation/update via Github V3 Rest API, however the only downside is that for each file I have a commit. There is a possibility to do the same for multiple files, but unfortunately it involves some…
elect
  • 6,765
  • 10
  • 53
  • 119
0
votes
1 answer

Squash a merge commit with the first commit on a branch

I have a commit and a merge commit after it. I want to squash the merge commit with the first commit on the same branch. Can someone explain how this can be done? Screenshot of git rebase -i -r
0
votes
1 answer

Squash merge and deleted image files

I have a feature branch in which I mistakenly committed a large image file, but then later deleted the file within the same feature branch. The branch was pushed up before the deletion (I don't think that matters). If I squash merge this branch into…
Faust
  • 15,130
  • 9
  • 54
  • 111
0
votes
2 answers

Git: Squash commits older than conflicting merge

I would like to squash some commits that are older than a "conflicting" merge. E.g.: main branch: A--B--C--D--G--H dev branch: \-E--F----/ H is my current head, G is the conflicting merge (so a merge in which I resolved conflicts manually) and…
Marius Melzer
  • 863
  • 1
  • 7
  • 10
0
votes
3 answers

Lost changes during squash with rebase

I try to run git rebase -i HEAD~N to squash my older commits into one. But sometimes I got a Merge conflict. The problem is, even if I resolve the conflict and do a "git rebase --continue", I lost a lot of my other commit changes. I also tried to…
Paxi
  • 111
  • 11
0
votes
1 answer

Git squash commits to reduce space by zip files

I am dealing with a repo that for reasons I can't do anything about have zip files that get to few mb and often change with each commit. I understand that means git is storing a complete copy of each zip for each commit, rather than deltas. We are…
Robert Mark Bram
  • 8,104
  • 8
  • 52
  • 73
0
votes
1 answer

Git squash last six commits after requested for PR in upstream

I requested pr#1 from origin/master to upstream. Then I created a new branch ipython_feature while checkout in the master. Before merging pr#1 I requested pr#2 which has some changes with pr#1. Later mt pr#1 has merged successfully. Now I could…