Skip to main content
Improved formatting
Source Link
Machavity
  • 31.3k
  • 27
  • 95
  • 103

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:

  1. Checkout the golden repo

    git checkout golden_repo_name

     git checkout golden_repo_name
    
  2. Create a new branch from it(golden repo) as follows

    git checkout -b dev-branch

     git checkout -b dev-branch
    
  3. Squash merge with your local branch that you have already

    git merge --squash feature-branch

     git merge --squash feature-branch
    
  4. 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"
    
  5. Push the branch to your local repository

    git push origin dev-branch

     git push origin dev-branch
    

If you are on a remote branch(called feature-branch) cloned from a Golden Repository(golden_repo_name), then here's the technique to squash your commits into one:

  1. Checkout the golden repo

    git checkout golden_repo_name

  2. Create a new branch from it(golden repo) as follows

    git checkout -b dev-branch

  3. Squash merge with your local branch that you have already

    git merge --squash feature-branch

  4. Commit your changes (this will be the only commit that goes in dev-branch)

    git commit -m "My feature complete"

  5. Push the branch to your local repository

    git push origin dev-branch

If you are on a remote branch(called feature-branch) cloned from a Golden Repository(golden_repo_name), then here's the technique to squash your commits into one:

  1. Checkout the golden repo

     git checkout golden_repo_name
    
  2. Create a new branch from it(golden repo) as follows

     git checkout -b dev-branch
    
  3. Squash merge with your local branch that you have already

     git merge --squash feature-branch
    
  4. Commit your changes (this will be the only commit that goes in dev-branch)

     git commit -m "My feature complete"
    
  5. Push the branch to your local repository

     git push origin dev-branch
    
Source Link

If you are on a remote branch(called feature-branch) cloned from a Golden Repository(golden_repo_name), then here's the technique to squash your commits into one:

  1. Checkout the golden repo

    git checkout golden_repo_name

  2. Create a new branch from it(golden repo) as follows

    git checkout -b dev-branch

  3. Squash merge with your local branch that you have already

    git merge --squash feature-branch

  4. Commit your changes (this will be the only commit that goes in dev-branch)

    git commit -m "My feature complete"

  5. Push the branch to your local repository

    git push origin dev-branch