Skip to content

Instantly share code, notes, and snippets.

@peavers
Last active February 13, 2024 15:47
Show Gist options
  • Save peavers/56dab97a16ef8090638d5309e158ec89 to your computer and use it in GitHub Desktop.
Save peavers/56dab97a16ef8090638d5309e158ec89 to your computer and use it in GitHub Desktop.
Quick helper for git commands when dealing with fussy tech leads
##################
# Squashing all commits to a single commit on your feature branch
git checkout feature_branch
git reset --soft develop #Whatever branch you're merging into
git add -A
git commit -m "feat: Add new meaningful feature"
git push
##################
# When you've got merge conflicts between your branch and develop
git checkout develop
git pull origin develop
git checkout feature_branch
git rebase develop
# Solve the commit issues, then execute:
git rebase --continue
# If not more issues, push to remote
git push --force-with-lease
##################
# How to rename a remote branch
git branch new_branch_name origin/old_branch_name
git push origin --set-upstream new_branch_name
git push origin :old_branch_name # Deletes remote branch
##################
# How to change git author for one last commit
git commit --amend --author="Author Name <[email protected]>" --no-edit
@peavers
Copy link
Author

peavers commented Feb 13, 2024

git clean -fd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment