0

So I've clone single branch from my repo as follow:

git clone --depth 1 ${git.repo} --branch master --single-branch ${project.dir}

When I run git branch -a it's output something like this:

* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

On git server I have following branches:

master
dev
stage
qa
feature/11
feature/12
feature/15

Now, how can I grab/pull/fetch/update/whatever to get original information of my all branches?

sobi3ch
  • 2,555
  • 2
  • 31
  • 41
  • I believe this is what you're looking for: [Question in stackoverflow](http://stackoverflow.com/questions/3903817/pull-new-updates-from-original-github-repository-into-forked-github-repository) – ddemuro Nov 11 '15 at 13:02
  • Have you tried **git remote update** ? – Simon Nov 11 '15 at 13:08
  • Also I am wondering what your setup is that you require to clone just a single branch? You could also make a shallow clone and then checkout the desired branch. – Simon Nov 11 '15 at 13:13
  • @Simon `git remote update` doesn't work – sobi3ch Nov 12 '15 at 09:00
  • @Simon My process doesn't require this. I've deleted this repo and do as mention but I just wondering is it possible at all. – sobi3ch Nov 12 '15 at 09:04
  • @ddemuro Looks like solution but not very simple. – sobi3ch Nov 12 '15 at 09:05

1 Answers1

0

@sobi3ch consider this content in .git/config file contents:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true

[remote "origin"]
    url = git@........git
    fetch = +refs/heads/*:refs/remotes/origin/*
    push = HEAD

[remote "github"]
    url = git@........git
    fetch = +refs/heads/*:refs/remotes/github/*

[remote "newrepo"]
    url = git@........git
    fetch = +refs/heads/*:refs/remotes/github/*

Now since you have your own repo "newrepo" to work with but at times you feel like pulling contents out of the original repo... you can do all the commands specifying where to pull differences from.

So the steps would be, clone that single branch. Push to your new repo only this branch

(git push -u newrepo branchname) for example.

Hope this answers essentially the question. By the way, newrepo will only have the cloned content from original repo, and the changes you provide, regardless where they come from.

I'd also protect myself from using common "origin", by removing it.

I wouldn't use git remote update, that will act against all remotes.

ddemuro
  • 26
  • 3