Nikaido
Nikaido

Reputation: 4629

Keeping a branch from a repository synchronized with a new stand-alone repository

I got a repo git in which I developed a stand-alone project on a branch. This repo is on a server in which it's used as active service. Because of this I cannot move it or delete it.

Now I need to create a stand-alone repo git on another server, which contains only this branch, but keeping It updated\sync with the old repository-branch, and only that.

For now I have created a new repository on the new server, putting in it the branch's files. But that's not really an elegant way. There is a more simple and elegant way to do it?

SERVER 1
repo git 1
-- branch "project"

SERVER 2
repo git 2
"project"

Something like:

me@server2:/repogit2 git fetch from repogit1 --branch "project"

Upvotes: 0

Views: 43

Answers (1)

dNitro
dNitro

Reputation: 5345

You can specifically clone just the desired branch with:

git clone -b <branchName> <remoteAddress>

Now you have got a repo that is consist of branchName branch that is tracking its peer branch on remoteAddress. You can confirm it by git branch -vv. now you can git fetch, git pull, git push and ... without the need of specifying remote and branch options.

Upvotes: 2

Related Questions