![]() As usual, I ran the git rebase -i command to do an interactive rebase, but I noticed that the root commit didnt appear in the list of commits. When I closed the editor, I was greeted by Successfully rebased and updated refs/heads/feature/add-version-login. How to Squash the First Two Commits in a Git Repository NovemI recently needed to squash the first two commits in one of my Git repositories. Where f stands for fixup which discard the commit’s log message. I wanted to squash b9e4be5 into 127db81, but I did not care about the commit message, so I changed the first lines to pick 127db81 Add app version to login screen # Note that empty commits are commented out # However, if you remove everything, the rebase will be aborted. # If you remove a line here THAT COMMIT WILL BE LOST. ![]() # These lines can be re-ordered they are executed from top to bottom. message (or the oneline, if no original merge commit was create a merge commit using the original merge commit's # l, label = label current HEAD with a name # b, break = stop here (continue rebase later with 'git rebase -continue') # x, exec = run command (the rest of the line) using shell # f, fixup = like "squash", but discard this commit's log message # s, squash = use commit, but meld into previous commit # e, edit = use commit, but stop for amending # r, reword = use commit, but edit the commit message # Rebase b3fe2b2.b9e4be5 onto b3fe2b2 (2 commands) Pick b9e4be5 Uncomment code for local dev Which opens an editor pick 127db81 Add app version to login screen The solution is to squash the latest commit into the previous one: git rebase -i HEAD~2 Now the history of the repository is not clean, there is a uncomment code for local dev commit that I did not like. So I uncommented that code and committed again. I made the changes and committed, and then I realized that the code was still commented. On the same note of yesterday’s article, today I worked on a very small change, but I had to comment some code to be able to test locally, without the need to connect to the real backend.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |