On Mon, Feb 12, 2018 at 9:28 AM <rhkra...@gmail.com> wrote:
> I'm a newbie to git, but from what I've learned so far, I want to have
> both a
> working git repository and a "bare" git repository for some development I
> to do.
> I've seen two ways to create a bare repository (iirc, init --bare ... and
> clone --bare ...) , and I've had a few problems using those so far.
> I'm wondering if a third way will work--I would propose to copy the entire
> contents of my working repository to another directory, then delete all
> is not under the .git directory, and then rename the .git directory to git.
That would probably work, but I think there is an easier way to resolve
your concern for losing work from your working repository.
Create a bare repository cloned from the origin repository
$ mkdir -p ~/git/bare
$ cd ~/git/bare
$ git clone --bare git@server:directory/repo.git
Create a working repository cloned from the origin repository (reference
the bare repository if the repository is large)
$ mkdir -p ~/git
$ cd ~/git
$ git clone --reference ~/git/bare/repo.git git@server:directory/repo.git
Add the bare repository as a remote of the working repository
$ cd ~/git/repo
$ git remote add bare ~/git/bare/repo.git
Make changes in the working repository
$ git checkout -b feature-branch
$ git commit -m "Your message" your-file
Push changes to both the origin repository and the bare repository
$ git push origin --set-upstream feature-branch
$ git push bare
That sequence keeps a separate local git repository in the ~/git/bare/
directory in addition to the origin repository.
However, it has the negative that the separate copy is only updated if you
"git push bare".
I've used the technique with large repositories that I didn't want to clone
entirely from the origin after making some major mistake in the working
AFAICT, this should work (although maybe I need to completely remove the
> directory level and move it to the parent).
> In other words, assume I have:
> .../scite with a work space and a .git directory
> I would plan to copy this to:
> .../back/scite with no workspace but a git directory
> .../back/scite with no workspace and the content of the git directory
> (no git subdirectory)
> Am I setting a trap for myself?
> Some background:
> I am paranoid about losing work, and having a hidden directory (.git)
> where I
> am doing development makes me more paranoid (in the past, I have done
> like delete directories with hidden subdirectories or files because I
> about the hidden stuff). So, as I develop, after I commit to the
> .../scite/.git repository, I plan to push to the .../back/scite repository.
> You received this message because you are subscribed to the Google Groups
> "Git for human beings" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to git-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Git
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.