If you are on a remote branch(called feature-branchfeature-branch
) cloned from a Golden Repository(golden_repo_namegolden_repo_name
), then here's the technique to squash your commits into one:
Checkout the golden repo
git checkout golden_repo_name
git checkout golden_repo_name
Create a new branch from it(golden repo) as follows
git checkout -b dev-branch
git checkout -b dev-branch
Squash merge with your local branch that you have already
git merge --squash feature-branch
git merge --squash feature-branch
Commit your changes (this will be the only commit that goes in dev-branch)
git commit -m "My feature complete"
git commit -m "My feature complete"
Push the branch to your local repository
git push origin dev-branch
git push origin dev-branch