git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RFC: script to add another remote

From
PRPavel Roskin <proski@gnu.org>
Date
Feb 22, 2007, 22:16 UTC
Message-ID
<1172182595.20817.26.camel@dv>
Hello!

I'm trying to find the best way to add a new remote to an existing repository, create a local branch for it and make it easy to switch to that branch and back and to update all branches.

This is important because some Linux developers want to publish their branches without having to serve the whole Linux repository, which is about 175Mb even if packed with repack.usedeltabaseoffset=true.

I have written a simple script "git-clone-more" to help users who want to track more than one remote:

#!/bin/sh
set -e
if test $# -lt 2 || test $# -gt 4; then
	echo "Usage: git-clone-more URL REMOTE [BRANCH [REMBRANCH]]" >&2
	exit 1
fi
URL=$1
REMOTE=$2
BRANCH=${3-$REMOTE}
REMBRANCH=${4-master}
git-remote add "$REMOTE" "$URL"
git-fetch "$REMOTE"
git-config branch."$BRANCH".remote "$REMOTE"
git-config branch."$BRANCH".merge refs/heads/"$REMBRANCH"
git-checkout -b "$BRANCH" remotes/"$REMOTE"/"$REMBRANCH"

If there is any easier way to do the same thing? Maybe we could extend one of the git commands or make the above script another git command?

It's interesting that git-clone-more can be used instead of git-clone. I can use it e.g. to check out git in an empty directory:

git-init git-clone-more git://www.kernel.org/pub/scm/git/git.git git

-- 
Regards,
Pavel Roskin
Next: Junio C Hamano
Message 1 of 6 in “RFC: script to add another remote”
  1. Pavel RoskinFeb 22, 2007
  2. Junio C HamanoFeb 22, 2007
  3. Pavel RoskinFeb 23, 2007
  4. Junio C HamanoFeb 23, 2007
  5. Pavel RoskinFeb 23, 2007
  6. Junio C HamanoFeb 23, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.