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

[PATCH] git-clone-pack: do not silently overwrite an existing branch 'origin'

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 22, 2005, 17:59 UTC
Message-ID
<Pine.LNX.4.63.0512221859110.20025@wbgn013.biozentrum.uni-wuerzburg.de>

When cloning a repository which already contains a branch called 'origin', do not silently overwrite it with the remote 'master' ref.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
	This happened to me with a project I track via git-cvsimport.
	The clone strangely suffered a time warp ;-)
 git-clone.sh |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
f0d4ef72573488410a1e8eb0198e347630d6e2c9
diff --git a/git-clone.sh b/git-clone.sh
index 280cc2e..e988964 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -204,6 +204,10 @@ then
 	head_points_at=`git-symbolic-ref HEAD`
 	case "$head_points_at" in
 	refs/heads/*)
+		if test -e .git/refs/heads/origin; then
+			chmod a-w .git/refs/heads/origin
+			echo "Warning: branch 'origin' exists already"
+		fi
 		head_points_at=`expr "$head_points_at" : 'refs/heads/\(.*\)'`
 		mkdir -p .git/remotes &&
 		echo >.git/remotes/origin \
-- 
1.0.0
Next: Junio C Hamano
Message 1 of 3 in “git-clone-pack: do not silently overwrite an existing branch 'origin'”
  1. git-clone-pack: do not silently overwrite an existing branch 'origin'Johannes Schindelin, Dec 22, 2005
  2. Junio C HamanoDec 22, 2005
  3. Johannes SchindelinDec 22, 2005

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.