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

  • Home
  • SEARCH
  • 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 8745461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:01:01+00:00 2026-06-13T12:01:01+00:00

I have a git repository for a web site, where the master branch represents

  • 0

I have a git repository for a web site, where the master branch represents production code. I have been asked to set up a ‘sandbox’ version of the site, for potential users of the system to experiment in so they don’t have to do that in the production system.

Because the sandbox version of the site needs to be clearly labelled as such, and have some functionality disabled, I have created a sandbox branch (based off master) and made some commits there to add warning messages and so on.

I have then pushed both branches upstream, and on the web server I have checked out each branch in a separate directory – one for production and one for the sandbox.

This works fine, but the problem comes when I want to write more code. Once I commit the code to the master branch, it will be updated in the production system but the sandbox won’t see the new code. So I rebase the sandbox branch onto master, so the commits for the sandbox always sit on top of production. But then of course once I’ve done that, I can no longer push the sandbox branch upstream because it’s no longer a fast-forward. I have to log in to the git server, switch branches, do a soft reset then redo the push.

Surely there’s a better way of doing this with git? What I really need is some way of consistently applying some commits on top of whatever branch is currently checked out.

  • 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-06-13T12:01:02+00:00Added an answer on June 13, 2026 at 12:01 pm

    You can do a non-fast-forward push with git push remote +branch. However the receiving git repository can be configure to reject these.

    However you might run into slight problems if you have edits to an old version of the branch but have pushed a rebased version upstream. One way to work around this is the following:

    # you are on branch X and origin/X has been force-updated
    git branch X-tmp   # keep a reference to your new commits
    git fetch origin
    git reset --hard origin/X   # now X is the same as origin/X
    
    # now you have two options
    # option 1: move the new commits from X-tmp to X by cherry-picking
    # them one-by-one
    git cherry-pick abc123
    git cherry-pick def456
    
    # option 2: this rebase should do the right thing and detect the equivalent
    # commits in X and X-tmp
    git checkout X-tmp
    git rebase X
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Git repository which I have started to develop on master branch
I have a Azure Web Site that is linked with a Git Repository (in
I have a git repository hosted on BitBucket, and have set up SSH authentication
I have a git repository (at github.com) with two branches: master and gh-pages. I
Trying to set-up a git server on my local dev machine and have been
I've been planning on using GIT for version control. However, I have a prolly
I have been working on a system to push changes from my git repository
I'm trying to set up my first Git Repository on GitHub. I've been following
I have a git repository with remote foo. foo is a web app, is
Suppose I have Git repository like this: git-repo/ directory_1/ directory_2/ directory_3/ This has a

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.