Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7503753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:20:32+00:00 2026-05-29T21:20:32+00:00

Suppose I was on master branch and created a new branch: git checkout -b

  • 0

Suppose I was on master branch and created a new branch:

git checkout -b feature_branch

I started to work on feature_branch, and at some point I would like to merge my changes to master using rebase. So, I do:

# Get the latest code on master
git checkout master
git pull

# Rebase on master and push the most updated 'feature_branch'
git checkout feature_branch
git rebase master
git push

# Merge 'feature_branch' to 'master' and push the updated 'master'
git checkout master
git merge feature_branch
git push

# Back to work on 'feature_branch'
git checkout feature_branch

Is there a way to reduce the number of steps and achieve the same?

At the end of the process I would like master, origin/master, feature_branch, and origin/feature_branch, to point to the same commit.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:20:34+00:00Added an answer on May 29, 2026 at 9:20 pm

    You can remove a couple commands. This does the same:

    # you have to have the branch checked out to pull, since pulling means merging
    # into master, and you need a work tree to merge in
    git checkout master
    git pull
    
    # no need to check out first; rebase does the right thing with two arguments
    git rebase master feature_branch
    
    git checkout master
    git merge feature_branch
    
    # git push by default pushes all branches that exist here and on the remote
    git push
    
    git checkout feature_branch
    

    Strictly speaking, the merge into master is guaranteed to be a fast-forward (a trivial merge), so it doesn’t actually need a work tree, but there’s not really a built-in way skip the checkout. There are workarounds, e.g. pushing into the same repository: git push . feature_branch:master (safe, but weird) or directly updating the ref: git update-ref master feature_branch (unsafe – doesn’t check if it’s a fast-forward) but generally you might as well just quickly switch branches.

    Also note that if you didn’t want to rebase the feature branch, you could just skip that, not rewrite feature_branch, and end up with a merge commit in master instead of the rebased feature_branch and fast-forward merge.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I created a new branch from master and eventually merge the changes back,
Suppose I have a git repos that contains original.script . At some point, I
Suppose I have my master branch checked out. I've committed some production changes to
I would like to know if the following is possible in git: Suppose I
Suppose I merge a branch to the master. Since I do not want to
Suppose your git history looks like this: 1 2 3 4 5 1–5 are
Like most people new to Git, I've had my share of confusion trying to
Suppose I have a Site.Master page. I want to display something like the version
Say I created a feature-x branch and merged or rebased with master branch. Now
Suppose we start with a brand new setup. touch somefile git init . git

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.