Git Operations: A Comprehensive Guide
Git is an essential tool for version control, widely used by developers. In this guide, we'll walk through common Git operations that every developer should know. Bookmark this page as we’ll continue adding more operations in the future.
Combine All Pushed Commits into One Method 1
To clean up your commit history and combine multiple commits into a single one, follow these steps:
1. Count the total commits on the live branchcommand: git log
description: this will show all the commits on git you just need to count where is your branch name2. Rebase the last X commits:
command: git rebase -i HEAD~6
description: instead of 6 you need to write a number of commits that you found in step 1
3. Edit the commits: A terminal console will appear with all the commits labeled "pick."
Press i
to enter insert mode.Replace the word pick
withsquash
for all but not for the first commit.4. Save and exit:
PressEsc
, then type:wq
and hit enter.5. Push the changes:
git push origin your-branch-name --force
0 comments: