threads / discuss / 30031

Push from specific directory.

Subject: Push from specific directory.

## tl;dr

11 messages between Mar 22, 2012 and Mar 26, 2012.

replies: 10people: 5as markdown or json

Anjib Mulepati· Mar 22, 2012, 22:04 UTC · lore
Hi All
I am starting using Git and few queries about it.
1. Is it always necessary to be in root directory to do the push?
2. Can I have a folder structure like
         (a) /Hello-World
         (b) /Hello-World/gitVersion/GitVersionFile.txt and
         (c) /Hello-World/nonGitVersion/NonGitVersionFile.txt
where I give git init for (a) and (c). If Itry to push only from (c) is 
that valid?

Thanks, Anjib

Jeff King· Mar 22, 2012, 22:57 UTC · re: Anjib Mulepati · lore

Re: Push from specific directory.

On Thu, Mar 22, 2012 at 06:04:20PM -0400, Anjib Mulepati wrote:
> 1. Is it always necessary to be in root directory to do the push?

No. You are pushing whole commits, not a particular subset of your working tree. So doing it from anywhere in the repository should have the same effect.

But...
Show 6 quoted lines
> 2. Can I have a folder structure like
>         (a) /Hello-World
>         (b) /Hello-World/gitVersion/GitVersionFile.txt and
>         (c) /Hello-World/nonGitVersion/NonGitVersionFile.txt
> where I give git init for (a) and (c). If Itry to push only from (c)
> is that valid?

You have a repository inside a repository. So when you are in (c), you will be pushing the commits from (c), not from (a). I'm not really sure what you are trying to accomplish with that.

-Peff
Neal Kreitzinger· Mar 22, 2012, 23:22 UTC · re: Jeff King · lore

Re: Push from specific directory.

On 3/22/2012 5:57 PM, Jeff King wrote:
Show 11 quoted lines
> On Thu, Mar 22, 2012 at 06:04:20PM -0400, Anjib Mulepati wrote:
>
>> 2. Can I have a folder structure like (a) /Hello-World (b)
>> /Hello-World/gitVersion/GitVersionFile.txt and (c)
>> /Hello-World/nonGitVersion/NonGitVersionFile.txt where I give git
>> init for (a) and (c). If Itry to push only from (c) is that valid?
>
> You have a repository inside a repository. So when you are in (c),
> you will be pushing the commits from (c), not from (a). I'm not
> really sure what you are trying to accomplish with that.
>

See this thread for the "cons" of nested git repos: (I don't think there are any "pros".) http://thread.gmane.org/gmane.comp.version-control.git/190372

*If* that is really what you meant...

v/r, neal

Jeff King· Mar 22, 2012, 23:27 UTC · re: Neal Kreitzinger · lore

Re: Push from specific directory.

On Thu, Mar 22, 2012 at 06:22:13PM -0500, Neal Kreitzinger wrote:
Show 7 quoted lines
> >You have a repository inside a repository. So when you are in (c),
> >you will be pushing the commits from (c), not from (a). I'm not
> >really sure what you are trying to accomplish with that.
> >
> See this thread for the "cons" of nested git repos: (I don't think
> there are any "pros".)
> http://thread.gmane.org/gmane.comp.version-control.git/190372

Nested git repos are OK. I use one inside my git.git checkout to hold meta-information and scripts (and I know Junio does the same thing). But I mark the sub-repository as ignored in the parent repository. What's insane is trying to track the same set of files from two different repositories. And I think that is the confusing case in the thread you mentioned.

-Peff
Neal Kreitzinger· Mar 22, 2012, 23:56 UTC · re: Jeff King · lore

Re: Push from specific directory.

On 3/22/2012 6:27 PM, Jeff King wrote:
Show 17 quoted lines
> On Thu, Mar 22, 2012 at 06:22:13PM -0500, Neal Kreitzinger wrote:
>
>>> You have a repository inside a repository. So when you are in (c),
>>> you will be pushing the commits from (c), not from (a). I'm not
>>> really sure what you are trying to accomplish with that.
>>>
>> See this thread for the "cons" of nested git repos: (I don't think
>> there are any "pros".)
>> http://thread.gmane.org/gmane.comp.version-control.git/190372
>
> Nested git repos are OK. I use one inside my git.git checkout to hold
> meta-information and scripts (and I know Junio does the same thing). But
> I mark the sub-repository as ignored in the parent repository.  What's
> insane is trying to track the same set of files from two different
> repositories. And I think that is the confusing case in the thread you
> mentioned.
>

Yes, hopefully the nested git repo is ignored by the higher level git repo. However, if it was ignored I don't suspect one would be wondering if it was ok to "only" push from the nested repo. I could be wrong.

v/r, neal

Junio C Hamano· Mar 22, 2012, 23:53 UTC · re: Neal Kreitzinger · lore

Re: Push from specific directory.

Neal Kreitzinger <nkreitzinger@gmail.com> writes:
> See this thread for the "cons" of nested git repos: (I don't think
> there are any "pros".)
> http://thread.gmane.org/gmane.comp.version-control.git/190372

Hmph, I see you saying "I will keep this in mind" and "Thanks" at the end, and back then I took it that you understood why/how nested working trees are useful. Perhaps you didn't and I misunderstood you?

Neal Kreitzinger· Mar 23, 2012, 00:09 UTC · re: Junio C Hamano · lore

Re: Push from specific directory.

On 3/22/2012 6:53 PM, Junio C Hamano wrote:
Show 9 quoted lines
> Neal Kreitzinger<nkreitzinger@gmail.com>  writes:
>
>> See this thread for the "cons" of nested git repos: (I don't think
>> there are any "pros".)
>> http://thread.gmane.org/gmane.comp.version-control.git/190372
>
> Hmph, I see you saying "I will keep this in mind" and "Thanks" at the end,
> and back then I took it that you understood why/how nested working trees
> are useful.  Perhaps you didn't and I misunderstood you?

I neglected to distinguish between ignored-nested-git-repos (has pros) and tracked-subdir-nested-git-repos (has no pros) in my preface to the thread link. That was an oversight on my part.

BTW, I'm am still being compelled to deal with tracked-subdir-nested-git-repos and I have not found any pros to them so your original assessment of that technique still stands. ;-)

v/r, neal

Neal Kreitzinger· Mar 23, 2012, 01:29 UTC · re: Jeff King · lore

Re: Push from specific directory.

On 3/22/2012 5:57 PM, Jeff King wrote:
Show 11 quoted lines
> On Thu, Mar 22, 2012 at 06:04:20PM -0400, Anjib Mulepati wrote:
>
>> 2. Can I have a folder structure like (a) /Hello-World (b)
>> /Hello-World/gitVersion/GitVersionFile.txt and (c)
>> /Hello-World/nonGitVersion/NonGitVersionFile.txt where I give git
>> init for (a) and (c). If Itry to push only from (c) is that valid?
>
> You have a repository inside a repository. So when you are in (c),
> you will be pushing the commits from (c), not from (a). I'm not
> really sure what you are trying to accomplish with that.
>

It almost looks like he might be tracking his git installation with git by tracking the "gitVersion" dir, and the "NonGitVersion" dir is really the "normal" git repo containing a dev project. I'm probably making a misinterpretation of the wording and "gitVersion" means "stuff versioned by git", but then again "NonGitVersion" is also supposedly being versioned by git. Just curious if he's attempting to use his git installation to track itself which would be interesting also.

v/r, neal

Neal Kreitzinger· Mar 23, 2012, 15:30 UTC · lore

Re: Push from specific directory.

On 3/23/2012 8:35 AM, Anjib Mulepati wrote:
Show 9 quoted lines
> I  am comparing Git with other SVN.
>
> In SVN each folders have .svn folder. If we don't wanna track 
> particular folder then there is no .svn folder in that directory. In 
> Git does we have same structure?
>
> So the example I am giving here represent two versions and one 
> non-version folder.
>

There is only one .git dir per git repo. By default it is created under the top-level dir (worktree) of the repo. If you don't want to track a subdir then you ignore it using the gitignore technology of git. You would want to setup the gitignore before doing the init.

v/r, neal

Holger Hellmuth· Mar 26, 2012, 14:27 UTC · re: Neal Kreitzinger · lore

Re: Push from specific directory.

On 23.03.2012 16:30, Neal Kreitzinger wrote:
> You would want to setup the gitignore before doing the init.
Why that? "git init" doesn't add any files, the repo is still empty.

I would even say "git init" helps because you get a comprehensive list of non-ignored files with "git status" and can sift through that list for files you want to be ignored

Neal Kreitzinger· Mar 26, 2012, 14:41 UTC · re: Holger Hellmuth · lore

Re: Push from specific directory.

On 3/26/2012 9:27 AM, Holger Hellmuth wrote:
Show 11 quoted lines
> On 23.03.2012 16:30, Neal Kreitzinger wrote:
>
>> You would want to setup the gitignore before doing the init.
>
> Why that? "git init" doesn't add any files, the repo is still empty.
>
> I would even say "git init" helps because you get a comprehensive list 
> of non-ignored files with "git status" and can sift through that list 
> for files you want to be ignored
>
>
Thanks for correcting that.

v/r, neal

← back to recent threads