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

Squashing Merged commits with Rebase

I have a branch feature/Install New feature on this branch and screens and having 11 commits. But all commits have merged commits. Planning to do a squash these commits. I have list of merged commits in a log history and need to squash into a single…
Sanjay Dutt
  • 1,173
  • 4
  • 15
  • 19
0
votes
2 answers

How can I parse arguments in a shell function and then make a multiline commit with it?

I'm following the conventional commits standard and I want to make a shell function to do a squash and merge and commit changes with a parsed message, improving my coding speed and my commits consistency. My problem is to parse the arguments and…
0
votes
2 answers

How do squashed commits compare to non-squashed?

Suppose I have a master branch, and a dev branch. After working in the dev branch, I squash and merge it into master git checkout master git merge --squash dev git commit This makes a new commit, right? But it seems like running git checkout dev;…
0
votes
1 answer

How to squash the commits before I merge into master?

I branched out from master and worked in my new branch branchA, I made a few commits in branchA and merged master now and then into branchA to keep it updated with the latest change. Now I want to squash my commits into one commit before I merge…
litaoshen
  • 1,762
  • 1
  • 20
  • 36
0
votes
3 answers

How to squash your commits when not being your recent ones

It seemed easy to squash your commits if these are your recent ones (Squash my last X commits together using Git) But what if I want to squash a few commits of my repo that are not the recent ones, say HEAD~3 to HEAD~6. Is there a way to do this?
vaskort
  • 2,591
  • 2
  • 20
  • 29
0
votes
1 answer

git rebase does not seem to squash commits

I have two branches. branch1 has the latest changes, the other (branch2) contains the most recent changes that are on the remote. So what I do is I get the most recent shared commit like so: SHA=$(git merge-base branch1 branch2) then I run…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

How to cleanup git history removing certain commits after they've been pushed?

What I'm trying to do: I completed a feature. git add -A; git commit -m "feature A complete" Then I realized I missed some things. git add -A; git commit -m "feature A missed something 1" git add -A; git commit -m "feature A missed something 2" git…
Alex Cory
  • 10,635
  • 10
  • 52
  • 62
0
votes
1 answer

How to rewrite a whole git history (squashing and rewording) without falling in conflicts?

I am working on code base that has about 5000 commits (including merges). I started interactive rebase to squash similar commits and reword weak commit messages. Before that I deleted some big files following this article. Yet, I have conflicts…
Assem
  • 11,574
  • 5
  • 59
  • 97
0
votes
2 answers

How to know which Git commits to squash in my branch when looking at history

As with many places we like to squash our commits, within our feature branches before merging to master. To do this we frequently squash commits with an interactive rebase (git rebase -i HEAD~10) before merging How do I know which commits to squash…
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
0
votes
1 answer

Did 'git rebase -i master' by mistake and unsure of current state

I'm working with a local repo and there are no upstream repos. I had a single branch 'master' in which HEAD referred to the most recent commit. In an attempt to accomplish something* I did a: git rebase -i master which brought up the editor…
Howiecamp
  • 2,981
  • 6
  • 38
  • 59
0
votes
1 answer

Git delete past commits from the tree as well as working directory

Currently, my git tree looks like this master ^ | Commit 3 ^ | Commit 2 ^ | …
trailblazer
  • 1,421
  • 5
  • 20
  • 43
0
votes
2 answers

Github repo squash commits on master

I'm working with a github repo where a lot of commits historically have been "bugfix", "bugfix for real this time", "ok final bugfix", "finally fixed". These were committed directly to master. How can I squash them? Fromt his post a year ago - it…
Don P
  • 60,113
  • 114
  • 300
  • 432
0
votes
1 answer

How to merge two incontinuous commits

I want to merge e5c1e1d and 627c6c6 How to do it ? I want an easier way. Because if there are hundreds commits between them, it will be very trouble to do rollback then re-commit. * fc60bec - (HEAD, master) Make db migrate (67 seconds ago) *…
newBike
  • 14,385
  • 29
  • 109
  • 192
0
votes
1 answer

How do I fix this git commit log?

I have a repository on Bitbucket. I kinda screwed up the commit log when I tried to squash the commits c265825 and 0a1837e: Trying to squash these commits resulted in 0942142, which is basically empty. What I mean is if I try and view that commit…
Big McLargeHuge
  • 14,841
  • 10
  • 80
  • 108
-1
votes
2 answers

squash hundreds of commits and rebase kicks off a large conflict resolution

I have a "long lived feature" branch that i have been working for last 2 months. It has 211 commits that i want to squash into single commit before this "long lived feature branch" can be merged with "origin master". When i run "git rebase -i…
ASy_Dev
  • 1
  • 1
1 2 3
14
15