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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:27:16+00:00 2026-05-20T10:27:16+00:00

I have 2 local git archives in /a and in /b which were cloned

  • 0

I have 2 local git archives in /a and in /b which were cloned from remotes/origin.

There is a new branch z on /b

How can I track and fetch branch z from archive /a ?

I tried this:

cd /a
git remote add b /b

This creates 2 config entries, but I did not manage to fetch something or to list remote branches on /a that would show the branches on /b


After trying different things I found the following that works:

1) git remote show b lists all the remote branches in b

2) I can fetch using this syntax:

git fetch file:///a/ z


Other things that also work:

$ cd /b
$ git checkout -b z
Switched to a new branch 'z'
$ git pull b z

But those commands still dont work and I cannot understand why:

git branch -a 

does not list the remote branches in b (onlz the ones in origin are shown)

git checkout -t b/z

Does not checkout anything but returns an error message

  • 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-20T10:27:17+00:00Added an answer on May 20, 2026 at 10:27 am

    So far you’ve only added b as a remote. You can try git branch -a to list your remote branches after you’ve fetched them.

    Here’s the commands to checkout the z branch from b:

    git remote add b /b              # you've already done
    git fetch b                      # get it so we can see it
    git checkout -t b/z              # check out a local tracking branch
    

    The -t (or --track) creates a tracking branch, otherwise you’ll be in detached head state.

    Then you should see:

    /a$ git branch
      master
    * z
    

    For anyone unclear on the steps involved, here’s what I did:

    create origin

    $ mkdir origin
    $ cd origin/
    /origin$ git init --bare
    Initialized empty Git repository in /origin/
    /origin$ cd ..
    

    clone ‘a’ and add some content

    $ git clone origin/ a
    Initialized empty Git repository in /a/.git/
    warning: You appear to have cloned an empty repository.
    $ cd a
    /a$ echo hi there > hello
    /a$ git add hello
    /a$ git ci -m'first commit'
    [master (root-commit) 0867b93] first commit
     1 files changed, 1 insertions(+), 0 deletions(-)
     create mode 100644 hello
    /a$ git push origin master 
    Counting objects: 3, done.
    Writing objects: 100% (3/3), 210 bytes, done.
    Total 3 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (3/3), done.
    To /origin/
     * [new branch]      master -> master
    

    clone ‘b’ and add more content on new branch

    /a$ cd ..
    $ git clone origin/ b
    Initialized empty Git repository in /b/.git/
    $ cd b
    /b$ git checkout -b z
    Switched to a new branch 'z'
    /b$ echo new guy reporting in >> hello 
    /b$ git ci -am "new recruits"
    [z 81044ee] new recruits
     1 files changed, 1 insertions(+), 0 deletions(-)
    

    Add ‘b’ as a remote to ‘a’

    /b$ cd ../a
    /a$ git remote add b ../b
    /a$ git fetch b
    remote: Counting objects: 5, done.
    remote: Total 3 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (3/3), done.
    From ../b
     * [new branch]      master     -> b/master
     * [new branch]      z          -> b/z
    /a$ git br
    * master
    /a$ git checkout -t b/z
    Branch z set up to track remote branch z from b.
    Switched to a new branch 'z'
    /a$ git br
      master
    * z
    

    I’ve put the above commands into a script so you can test it out yourself.

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

Sidebar

Related Questions

I have a local git repo cloned from bitbucket.com I do a lot of
Say I have an arbitrary local git working directory that was cloned from some
I have created local linux kernel git repository from which I want to check
Totally new to Capistrano. I have a local git repository that I want to
I accidentally deleted a few files from my local git repo. I have not
I have two git repositories: report.git (Master on remote location) cloned.git (Local) I lost
I have a git project which is only local, and only has a master
I have a local git repo created by Qt Creator during the New Project
I have a local git repository. Recently I have added a remote repository from
I currently have a local Git repository, which I push to a Github repository.

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.