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 9247095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:38:50+00:00 2026-06-18T09:38:50+00:00

Simplyfiing I have a created a git branch structure like this: Generated from: git

  • 0

Simplyfiing I have a created a git branch structure like this:

enter image description here

Generated from:

git init
echo "Hello World" > file1.txt
git add file1.txt
git commit -m "Hello world"
git checkout -b A
echo "This is from A branch" > file2.txt
git add file2.txt
git commit -m "from A branch"
git checkout -b B
echo "This is from B branch" >> file2.txt
git commit -a -m "from B branch"

Now I clone this structure and synchronize master, A and B branches:

git clone /path-to-source/
git checkout -b master remotes/origin/master
git checkout -b A remotes/origin/A

and the cloned repository reflects the source hierarchy:

enter image description here

Now I return to source folder and add something to master and rebase A and B:

cd /path-to-source/
git checkout master
echo "more files" > file3.txt
git add file3.txt
git commit -m "Improved master"
git checkout A
git rebase master
git checkout B
git rebase A

enter image description here

The problem comes when I return to the cloned repository and try to keep this structure. If I just pull the master branch, I get this:

enter image description here

I can go to every branch and update:

git checkout A
git pull

but I get branch trees like this:

enter image description here

The question is, how to keep a clean clone of the repository? It is, I want to obtain this (manipulated graphic) in the cloned repository:

enter image description here

Bonus: If possible, I would like to find a way to keep also commits in the A or B branches like this:

enter image description here

generated from these commands in the source repository:

git checkout A
echo "something" > other.txt
git add other.txt
git commit -m "Other A commit"
git checkout B
git rebase A

NOTE 1: If that helps, cloned repository NEVER commits
NOTE 2: You can assume that there is only 1 user commiting to source repository

  • 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-18T09:38:52+00:00Added an answer on June 18, 2026 at 9:38 am

    Rebasing means changing the SHA1, so your branch A in the clone is no longer valid.

    You can follow “How do I recover/resynchronise after someone pushes a rebase or a reset to a published branch?” to restore the cloned branch A (inspired from the “RECOVERING FROM UPSTREAM REBASE” section).

    But if:

    • those rebases are a frequent occurrence,
    • you don’t have any new commit on the clone for branch A and branch B

    You might want to simply reset those branches (on the clone) based on their origin/A and origin/B: you reset branch A HEAD to origin/A.

    git branch -f origin/A
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a simple command line tool that outputs hello world. This is
I have a test which looks a bit like this (I'm simplifying a bit
I have some nicely-structured data that looks like this: CREATE TABLE SourceBodyPartColors ( person_ID
This is a JavaScript/Ajax webpage (also using jQuery). I have a nested structure I
I have a data file with several lines set up like this: Simplifying or
I have a section of makefile that has this sort of structure: bob: ifdef
Imagine C# code like this ISomeInterface someVar = creator.Create(typeof(SomeClass), typeof(ISomeInterface)); What should happen? Method
I have been studying the bonjour/NSStream sample code from lecture #17 of Stanford's CS193p
I am simplifying a little here: I have a tab control, and should like
I'm simplifying this for my question, but, as an example, let's say I have

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.