Re: [git-users] Third way to create a bare repository?

2018-02-24 Thread rhkramer
Mark (and all),

Thanks very much for your help!  I think I've got it working now, and 
reviewing what you wrote helped me realize what I had missed, basically the 
step of "naming" the bare / remote repository with =git remote add=.

I thought I'd record (on the list) more precisely what I actually did both for 
my own records and for posterity.

I had to sort of translate what you did into what I needed to do--a major 
difference is that the code I want to work on is maintained in a Mercurial 
repository upstream--I don't need to or plan to push my changes back up to 
there until I've pretty much accomplished what I want to accomplish, and, at 
that point, I'll just make a patch file to send.

A more minor difference is that I need to work on two bodies of code, so I 
needed two working repositories and two corresponding local backup 
repositories, but I will show only the steps for one of them here.

I'm starting with a working repository created in /rhk03/sciscint_git/scite, 
the code body downloaded as a tarball, opened in /rhk03/sciscint_git/scite, 
and then git committed (into /rhk03/sciscint_git/scite/.git).  My intent is to 
setup a bare repository in /back03/sciscint_git/scite/git for regular pushes 
for backup.

Note that all asterisk are extraneous--they are a means of bolding text in my 
own notetaking system.

<*set up a parent directory on filesystem back03 for the bare / remote / backup 
repositories and move to it*>
=
rhk@s31:/*back03*$ mkdir sciscint_git
rhk@s31:/back03$ cd sciscint_git
=

<*create an empty directory under that parent directory and initialize it as 
an (empty) git repository (git init --bare )*>
=
rhk@s31:/*back03/sciscint_git$ git init --bare scite_remote/git*
Initialized empty Git repository in /back03/sciscint_git/scite_remote/

rhk@s31:/back03/*sciscint_git$ ls scite_remote/git*
branches  config  description  HEAD  hooks  info  objects  refs
=

<*name the backup bare repository as a remote of the working repository (from 
within the working repository on filesystem rhk03)*>
=
rhk@s31:/back03/sciscint_git/$ cd rhk03/sciscint_git/scite
rhk@s31:/*rhk03*/sciscint_git/*scite$ git remote add scite_remote 
/back03/sciscint_git/scite_remote/git*
=

<*if you make a mistake in naming (I made several, fixed since)*>
rhk@s31:/rhk03/sciscint_git/scite$ git remote remove 

<*to see (names of) remotes for a repository*>
rhk@s31:/rhk03/sciscint_git/scite$ git remote

<*first push from working repository to remote (backup) repository--first a dry 
run*>
=
rhk@s31:/*rhk03*/sciscint_git/*scite$ git push  --dry-run* --set-upstream 
scite_remote master
To /back03/sciscint_git/scite_remote/git
 * [new branch]  master -> master
Would set upstream of 'master' to 'master' of 'scite_remote'
rhk@s31:/rhk03/sciscint_git/scite$ 

rhk@s31:/*rhk03*/sciscint_git/*scite$ git push --set-upstream scite_remote 
master*
Counting objects: 302, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (301/301), done.
Writing objects: 100% (302/302), 979.01 KiB | 0 bytes/s, done.
Total 302 (delta 26), reused 0 (delta 0)
To /back03/sciscint_git/scite_remote/git
 * [new branch]  master -> master
Branch master set up to track remote branch master from scite_remote.
=





On Monday, February 12, 2018 12:42:37 PM Mark Waite wrote:
> On Mon, Feb 12, 2018 at 9:28 AM  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
> > want
> > 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 that
> > 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 

Re: [git-users] Third way to create a bare repository?

2018-02-12 Thread Mark Waite
On Mon, Feb 12, 2018 at 9:28 AM  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
> want
> 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
> that
> 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
repository.

Mark Waite

AFAICT, this should work (although maybe I need to completely remove the
> .git
> 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
>
> or:
>
>.../back/scite with no workspace and the content of the git directory
> here
> (no git subdirectory)
>
> Comments?
>
> 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
> things
> like delete directories with hidden subdirectories or files because I
> forgot
> 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 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[git-users] Third way to create a bare repository?

2018-02-12 Thread rhkramer
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 want 
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 that 
is not under the .git directory, and then rename the .git directory to git.

AFAICT, this should work (although maybe I need to completely remove the .git 
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

or:

   .../back/scite with no workspace and the content of the git directory here 
(no git subdirectory)

Comments?

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 things 
like delete directories with hidden subdirectories or files because I forgot 
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.