{"thread":{"id":"6161","subject":"What commands can and can not be used with bare repositories?","startedAt":"2006-12-31T01:48:22Z","lastAt":"2006-12-31T05:52:53Z","messageCount":6,"participants":["Theodore Ts'o","J. Bruce Fields","Shawn Pearce","Theodore Tso","Michael S. Tsirkin","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"30527","messageId":"E1H0poE-0000qd-Ee@candygram.thunk.org","threadId":"6161","inReplyTo":null,"subject":"What commands can and can not be used with bare repositories?","fromName":"Theodore Ts'o","fromEmail":"tytso@mit.edu","sentAt":"2006-12-31T01:48:22Z","receivedAt":"2006-12-31T01:48:22Z","isPatch":false,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"In order to minimize the amount of files which need to be backed up, I\ndecided to create an \"upstream\" repository which contains nothing but\nLinus's tree, which I packed into a single pack file, and which I would\nthen only update every 3-6 months.\n\nThe git tree(s) that I would use for Linux hacking would then use the\nupstream repository as an alternate source of objects.  That way the\n\"git gc\" command is much faster, and it doesn't end up thrashing the\nmain pack file found in the \"upstream\" repository (which is currently\nabout 135 megs).  This streamlines my backups a tad (every little bit\nhelps).\n\nThe only real problem with this is that I don't really need to have a\nworking directory in the \"upstream\" repository, so I decided to try\nusing a \"bare repository\".  This is only barely (sorry) documented in\nthe git Documentation, where in the git-clone manpage there is a\ndescription of how the administrative files end up in the top-level\ndirectory instead of the .git subdirectory.  \n\nWhat isn't documented is what commands actually can deal with a bare\nrepository.  At the moment, it looks like a bare repository can be a\ntarget of a git pull, push, and merge commands, and it can be a source\nfor a git clone, but that seems to be about it.  All other commands,\nsuch as \"git log\" blow up with the error message \"Not a git repository\".\nThis to me seems a bit lame, since why isn't a \"bare repository\" also a\n\"git repository\"?  All of the information is there for \"git log\" to\nwork.  Commands that require a working directory obviously can't work,\nbut there are plenty of git commands for which there's no reason why\nthey shouldn't be able to operate on a bare repository.  For example,\n\"git repack\", \"git log\", \"git fetch\", etc.\n\nSo as a suggestion, it would be good if exactly what you can and can't\nuse a \"bare repository\" for were documented.  If it really is push,\npull, fetch, and clone, I'll happily submit a patch to enhance the\ndocumentation accordingly.   \n\nThe next obvious question, though, is *should* that be all that works?\nA somewhat squinky hack that works quite nicely is to create a symlink\nfrom . to .git in the bare repository.  At this point \"git log\", \"git\nfetch\", \"git repack\", etc., all start working.  Of course, commands such\nas \"git status\" that involve a working directory will be pretty\nconfused, but maybe we could fix that.  What if we were to change \"git\nclone --bare\" to create the .git -> . symlink, and then add a check to\ncommands that require a working directory to see if \".git\" is a symlink\nto ., and if so, give an error message, \"operation not supported on bare\nrepository\"?\n\n\t\t\t\t\t- Ted\n"},{"id":"30528","messageId":"20061231015728.GB20348@fieldses.org","threadId":"6161","inReplyTo":"E1H0poE-0000qd-Ee@candygram.thunk.org","subject":"Re: What commands can and can not be used with bare repositories?","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2006-12-31T01:57:28Z","receivedAt":"2006-12-31T01:57:28Z","isPatch":false,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Sat, Dec 30, 2006 at 08:48:22PM -0500, Theodore Ts'o wrote:\n> What isn't documented is what commands actually can deal with a bare\n> repository.  At the moment, it looks like a bare repository can be a\n> target of a git pull, push, and merge commands, and it can be a source\n> for a git clone, but that seems to be about it.  All other commands,\n> such as \"git log\" blow up with the error message \"Not a git repository\".\n> This to me seems a bit lame, since why isn't a \"bare repository\" also a\n> \"git repository\"?  All of the information is there for \"git log\" to\n> work.  Commands that require a working directory obviously can't work,\n> but there are plenty of git commands for which there's no reason why\n> they shouldn't be able to operate on a bare repository.  For example,\n> \"git repack\", \"git log\", \"git fetch\", etc.\n\nYup.  Anything that should work actually does; you just need to know to\nuse one of:\n\n\tGIT_DIR=. git log\n\tgit --git-dir=. log\n\tgit --bare log\n\nWhy git couldn't figure this out for you, I don't know....\n\n--b.\n"},{"id":"30529","messageId":"20061231015732.GB5082@spearce.org","threadId":"6161","inReplyTo":"E1H0poE-0000qd-Ee@candygram.thunk.org","subject":"Re: What commands can and can not be used with bare repositories?","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-31T01:57:32Z","receivedAt":"2006-12-31T01:57:32Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Theodore Ts'o <tytso@mit.edu> wrote:\n> What isn't documented is what commands actually can deal with a bare\n> repository.  At the moment, it looks like a bare repository can be a\n> target of a git pull, push, and merge commands\n\nSorry but 'git merge' cannot be used in a bare repository (no working\ndirectory to update during the merge) and 'git merge' can only work on\nthe current repository, which rules out the bare repository.\n\n> and it can be a source\n> for a git clone, but that seems to be about it.  All other commands,\n> such as \"git log\" blow up with the error message \"Not a git repository\".\n\nTry \"git --bare log\".  Or \"git --git-dir=/path/to log\".\n\n> This to me seems a bit lame, since why isn't a \"bare repository\" also a\n> \"git repository\"?  All of the information is there for \"git log\" to\n> work.  Commands that require a working directory obviously can't work,\n> but there are plenty of git commands for which there's no reason why\n> they shouldn't be able to operate on a bare repository.  For example,\n> \"git repack\", \"git log\", \"git fetch\", etc.\n\nActually most commands work on a bare repository.\nVery few don't: the ones that require a working directory.\nE.g. status/revert/cherry-pick/commit/am/merge/pull.  (You can\npull from a bare repository, but you cannot run pull *in* a bare\nrepository.)\n\n> confused, but maybe we could fix that.  What if we were to change \"git\n> clone --bare\" to create the .git -> . symlink, and then add a check to\n> commands that require a working directory to see if \".git\" is a symlink\n> to ., and if so, give an error message, \"operation not supported on bare\n> repository\"?\n\nNo.  Better would be to make git's repository setup logic\nautomatically detect if \".\" is a Git repository, and if so let the\ncommands that work without a working directory run.\n\n-- \nShawn.\n"},{"id":"30532","messageId":"20061231021248.GA26067@thunk.org","threadId":"6161","inReplyTo":"20061231015732.GB5082@spearce.org","subject":"Re: What commands can and can not be used with bare repositories?","fromName":"Theodore Tso","fromEmail":"tytso@mit.edu","sentAt":"2006-12-31T02:12:49Z","receivedAt":"2006-12-31T02:12:49Z","isPatch":false,"sender":{"key":"tytso@mit.edu","avatar":"https://avatars.githubusercontent.com/u/51416?v=4"},"body":"On Sat, Dec 30, 2006 at 08:57:32PM -0500, Shawn Pearce wrote:\n> Try \"git --bare log\".  Or \"git --git-dir=/path/to log\".\n>\n> Actually most commands work on a bare repository.\n> Very few don't: the ones that require a working directory.\n> E.g. status/revert/cherry-pick/commit/am/merge/pull.  (You can\n> pull from a bare repository, but you cannot run pull *in* a bare\n> repository.)\n\nAh, right.  Thanks, I missed the --bare option.  It should probably be\nmentioned in the git-clone man page, instead of only in the top-level\ngit manpage.\n\n> > confused, but maybe we could fix that.  What if we were to change \"git\n> > clone --bare\" to create the .git -> . symlink, and then add a check to\n> > commands that require a working directory to see if \".git\" is a symlink\n> > to ., and if so, give an error message, \"operation not supported on bare\n> > repository\"?\n> \n> No.  Better would be to make git's repository setup logic\n> automatically detect if \".\" is a Git repository, and if so let the\n> commands that work without a working directory run.\n\nThat makes sense, although the hueristic for determining whether or\nnot \".\" is a Git repository might be a little interesting.  Say, if\nthere is no containing directory which has a .git directory, and the\ndirectories \"objects\", \"info\", and \"refs\" are present?\n\n\t\t\t\t\t\t- Ted\n"},{"id":"30553","messageId":"20061231053243.GB5240@mellanox.co.il","threadId":"6161","inReplyTo":"20061231021248.GA26067@thunk.org","subject":"Re: What commands can and can not be used with bare repositories?","fromName":"Michael S. Tsirkin","fromEmail":"mst@mellanox.co.il","sentAt":"2006-12-31T05:32:43Z","receivedAt":"2006-12-31T05:32:43Z","isPatch":false,"sender":{"key":"mst@kernel.org","avatar":null},"body":"> That makes sense, although the hueristic for determining whether or\n> not \".\" is a Git repository might be a little interesting.  Say, if\n> there is no containing directory which has a .git directory, and the\n> directories \"objects\", \"info\", and \"refs\" are present?\n\nMaybe, git clone --bare should create a special file under the\nrepository directory?\n\t\n-- \nMST\n"},{"id":"30557","messageId":"7v3b6wk3wq.fsf@assigned-by-dhcp.cox.net","threadId":"6161","inReplyTo":"20061231021248.GA26067@thunk.org","subject":"Re: What commands can and can not be used with bare repositories?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-31T05:52:53Z","receivedAt":"2006-12-31T05:52:53Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Theodore Tso <tytso@mit.edu> writes:\n\n> That makes sense, although the hueristic for determining whether or\n> not \".\" is a Git repository might be a little interesting.  Say, if\n> there is no containing directory which has a .git directory, and the\n> directories \"objects\", \"info\", and \"refs\" are present?\n\nWe have something called is_bare_git_dir() that does much\nsimpler and hacky check.\n\nSee my other message to Shawn regarding tradeoffs between\npossible improvements and backward compatibility.\n"}]}