Re: finding the right remote branch for a commit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Tue, 10 Jul 2007, martin f krafft wrote:

> I am trying to figure out a way to store ~/.etc in git. With SVN,
> I would have a .etc repository for each machine, which would use
> svn:externals to reference locations of the various subdirectories,
> which SVN would then pull and assemble. Thus, my ~/.etc might be
> 
>   ~/.etc
>   ~/.etc/ssh [svn+ssh://svn.madduck.net/priv/etc/ssh]
>   ~/.etc/vim [svn+ssh://svn.madduck.net/pub/etc/vim]
>   ...
>
> [...] 
> 
> Thus, the vim repository might look like this:
> 
>   .etc/
>   |-- vim/
>   |   `-- rc.vim
>   `-- .vimrc -> .etc/vim/rc.vim
> 
> and the ssh configuration might be
> 
>   .etc/
>   |-- ssh/
>   |   |-- config
>   |   `-- authorized_keys
>   `-- .ssh -> .etc/ssh/

Okay, after discussing this for a bit on IRC, here is what I would do (I 
already said this on IRC, but the mailing list is really the better medium 
for this):

I would actually rename .etc/ into gits/, because it is not a directory 
containing settings, but a directory containing repositories.

Then I would create bare repositories gits/vim.git/, gits/ssh.git/, 
gits/mutt.git/, etc. but as soon as I created them, I would make them 
"unbare", i.e. "git config core.bare false".

Everytime I would work on, say, .vimrc, I would say 
"--git-dir=$HOME/gits/vim.git", or maybe even make an alias in 
$HOME/.gitconfig, which spares me that:

$ git config --global vim '!git --git-dir=$HOME/gits/vim.git'

Then I could see the status with

$ git vim status

Come to think of it, this is maybe what I would have done, but it appears 
to me that this is the _ideal_ use case for worktree:

In $HOME/gits:

$ mkdir vim.git && cd vim.git
$ git --work-tree=$HOME init
$ cat >> info/exclude < EOF
*
!/.vimrc
EOF

Then you could do all Git operations like push, fetch, pull, log in 
$HOME/gits/vim.git, and all editing in $HOME.

At least that is the theory.

In practice, and I consider these all bugs, it does not work:

- you have to say

  $ git --work-tree=$HOME --bare init

  which is a bit counterintuitive.  After all, it is _not_ a bare 
  repository.  The whole purpose of worktree, as far as I understand, is 
  to have a _detached_ repository, which would otherwise be called bare.

- $ git status

  does not do what you would expect: it fails, telling you that it needs a 
  work tree, of all things. You can say (tongue-in-cheek)

  $ (export GIT_DIR="$(pwd)" && cd "$(git config core.worktree)" &&
     git status)

  So, git knows about the location of the working tree, but just ignores 
  that.

- In the case that you forget to set GIT_DIR, you better not have any 
  .git/ repository in $HOME/ or $HOME/gits/, because it will pick up that 
  instead!  Even if you are _inside_ a detached git directory!

  So you better not try some games like this in a subdirectory of your 
  local git.git repository.  It is a fine way to get completely confused.  
  And certainly do _not_ do something like "git reset --hard <branch>" 
  there.

- Of course, it would be nice if something like that worked:

  $ cd $HOME/gits/vim.git
  $ git add $HOME/.vimrc

  But it does not work, because it wants to _be_ in the work tree.  Of 
  course, you have to specify the GIT_DIR again, because the working tree 
  does not know about the location of the repository, but vice versa.

Those are serious bugs.  Matthias, any idea how to fix them?

Ciao,
Dscho

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux