All of lore.kernel.org
 help / color / mirror / Atom feed
* Definition of working directory
@ 2012-03-27 16:12 Anjib Mulepati
  2012-03-27 17:10 ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Anjib Mulepati @ 2012-03-27 16:12 UTC (permalink / raw)
  To: git

I was reading Git Community Book and came across following definition 
for working directory

The Working Directory

The Git 'working directory' is the directory that holds the current 
checkout of the files you are working on. Files in this directory are 
often removed or replaced by Git as you switch branches - this is 
normal. All your history is stored in the Git Directory; the working 
directory is simply a temporary checkout place where you can modify the 
files until your next commit.

What does it mean by this " Files in this directory are often removed or 
replaced by Git as you switch branches"?

And does working directory is just a directory we get with $pwd ?

Thanks,
Anjib

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Definition of working directory
  2012-03-27 16:12 Definition of working directory Anjib Mulepati
@ 2012-03-27 17:10 ` Junio C Hamano
  2012-03-27 21:26   ` Anjib Mulepati
  2012-03-28 14:10   ` Working directory managment Anjib Mulepati
  0 siblings, 2 replies; 11+ messages in thread
From: Junio C Hamano @ 2012-03-27 17:10 UTC (permalink / raw)
  To: Anjib Mulepati; +Cc: git

Anjib Mulepati <anjibcs@hotmail.com> writes:

> I was reading Git Community Book and came across following definition
> for working directory
>
> The Working Directory
>
> The Git 'working directory' is the directory that holds the current
> checkout of the files you are working on. Files in this directory are
> often removed or replaced by Git as you switch branches - this is
> normal. All your history is stored in the Git Directory; the working
> directory is simply a temporary checkout place where you can modify
> the files until your next commit.
>
> What does it mean by this " Files in this directory are often removed
> or replaced by Git as you switch branches"?

I think the common terminology for the concept the above describes is "the
working tree".

> And does working directory is just a directory we get with $pwd ?

After you clone, you have one directory that contains all the files from
one specific version in it.  The files may be organized into directory
hierarchy, but there is a single top-level directory.

That is the "working tree".  When we want to be absolutely clear, we may
even say "the top of the working tree", even though it may be redundant.

If you are at such a directory, $(pwd) may match it.  If you chdir to a
subdirectory from there, e.g. "cd Documentation", $(pwd) and the top of
the working tree will of course disagree.

The files checked out in the working tree represent the contents of the
version that was checked out, plus modifications you make locally.  When
you check out a different branch (people coming from svn background may
say "switch branch", but it is the same thing), the working tree will need
to represent the contents of the version at the tip of that different
branch.  If you have a file in the current branch but not in that
different branch you are checking out, that file has to go away.  If you
do not have a file in the current branch but not in that different branch
you are checking out, that file needs to be created in the working tree.
If the contents of a file is different between your current branch and the
branch you are checking out, the file in the working tree needs to be
updated to match that of the branch you are checking out. That is what the
"... are often removed or replaced" part is talking about.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Definition of working directory
  2012-03-27 17:10 ` Junio C Hamano
@ 2012-03-27 21:26   ` Anjib Mulepati
  2012-03-27 23:01     ` Junio C Hamano
                       ` (2 more replies)
  2012-03-28 14:10   ` Working directory managment Anjib Mulepati
  1 sibling, 3 replies; 11+ messages in thread
From: Anjib Mulepati @ 2012-03-27 21:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

So if I have a project called MyProject and inside that I have two 
sub-directories dir1 and dir2. Does that mean working directory is 
*ALWAYS* MyProject.

Also if i create some file in dir1 and do git status without git add 
then it display untracked files as ../dir1/
It doesn't display the untracked file name but after I do git add when I 
did git status it does give me file under changes to be committed. Why 
didn't it shows file with name as untracked in first case?

On 3/27/2012 1:10 PM, Junio C Hamano wrote:
> Anjib Mulepati<anjibcs@hotmail.com>  writes:
>
>> I was reading Git Community Book and came across following definition
>> for working directory
>>
>> The Working Directory
>>
>> The Git 'working directory' is the directory that holds the current
>> checkout of the files you are working on. Files in this directory are
>> often removed or replaced by Git as you switch branches - this is
>> normal. All your history is stored in the Git Directory; the working
>> directory is simply a temporary checkout place where you can modify
>> the files until your next commit.
>>
>> What does it mean by this " Files in this directory are often removed
>> or replaced by Git as you switch branches"?
> I think the common terminology for the concept the above describes is "the
> working tree".
>
>> And does working directory is just a directory we get with $pwd ?
> After you clone, you have one directory that contains all the files from
> one specific version in it.  The files may be organized into directory
> hierarchy, but there is a single top-level directory.
>
> That is the "working tree".  When we want to be absolutely clear, we may
> even say "the top of the working tree", even though it may be redundant.
>
> If you are at such a directory, $(pwd) may match it.  If you chdir to a
> subdirectory from there, e.g. "cd Documentation", $(pwd) and the top of
> the working tree will of course disagree.
>
> The files checked out in the working tree represent the contents of the
> version that was checked out, plus modifications you make locally.  When
> you check out a different branch (people coming from svn background may
> say "switch branch", but it is the same thing), the working tree will need
> to represent the contents of the version at the tip of that different
> branch.  If you have a file in the current branch but not in that
> different branch you are checking out, that file has to go away.  If you
> do not have a file in the current branch but not in that different branch
> you are checking out, that file needs to be created in the working tree.
> If the contents of a file is different between your current branch and the
> branch you are checking out, the file in the working tree needs to be
> updated to match that of the branch you are checking out. That is what the
> "... are often removed or replaced" part is talking about.
>
>
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Definition of working directory
  2012-03-27 21:26   ` Anjib Mulepati
@ 2012-03-27 23:01     ` Junio C Hamano
  2012-03-28  6:06     ` Kevin
  2012-03-28  9:40     ` jaseem abid
  2 siblings, 0 replies; 11+ messages in thread
From: Junio C Hamano @ 2012-03-27 23:01 UTC (permalink / raw)
  To: Anjib Mulepati; +Cc: git

Anjib Mulepati <anjibcs@hotmail.com> writes:

> So if I have a project called MyProject and inside that I have two
> sub-directories dir1 and dir2. Does that mean working directory is
> *ALWAYS* MyProject.

Your working tree is MyProject that has two subdirectories dir1 and dir2.

> Also if i create some file in dir1 and do git status without git add
> then it display untracked files as ../dir1/
> It doesn't display the untracked file name but after I do git add when
> I did git status it does give me file under changes to be
> committed. Why didn't it shows file with name as untracked in first
> case?

Because often such a directory has tons of garbage files that are totally
uninteresting.  Check "git help status" and look for the --untracked-files
option if you want to learn more.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Definition of working directory
  2012-03-27 21:26   ` Anjib Mulepati
  2012-03-27 23:01     ` Junio C Hamano
@ 2012-03-28  6:06     ` Kevin
  2012-03-28  9:40     ` jaseem abid
  2 siblings, 0 replies; 11+ messages in thread
From: Kevin @ 2012-03-28  6:06 UTC (permalink / raw)
  To: Anjib Mulepati; +Cc: Junio C Hamano, git

On Tue, Mar 27, 2012 at 05:26:23PM -0400, Anjib Mulepati wrote:
> So if I have a project called MyProject and inside that I have two
> sub-directories dir1 and dir2. Does that mean working directory is
> *ALWAYS* MyProject.

To be clear, the working directory or working tree is not necessarily a
path, but refers to the whole tree structure, so every file that belongs
to the repository.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Definition of working directory
  2012-03-27 21:26   ` Anjib Mulepati
  2012-03-27 23:01     ` Junio C Hamano
  2012-03-28  6:06     ` Kevin
@ 2012-03-28  9:40     ` jaseem abid
  2 siblings, 0 replies; 11+ messages in thread
From: jaseem abid @ 2012-03-28  9:40 UTC (permalink / raw)
  To: Anjib Mulepati; +Cc: Junio C Hamano, git

On Wed, Mar 28, 2012 at 2:56 AM, Anjib Mulepati <anjibcs@hotmail.com> wrote:
>
> So if I have a project called MyProject and inside that I have two
> sub-directories dir1 and dir2. Does that mean working directory is *ALWAYS*
> MyProject.

Yes. It is MyProject.

> Also if i create some file in dir1 and do git status without git add then
> it display untracked files as ../dir1/
> It doesn't display the untracked file name but after I do git add when I
> did git status it does give me file under changes to be committed. Why
> didn't it shows file with name as untracked in first case?

Often there will be build folders with too many unwanted files to
ignore. Unless at least a single file in a directory is tracked, git
will ignore the folder. This is afaik a good feature and not a
problem.

PS: I am not really a git expert. Please correct me if I'm wrong.

--
Jaseem Abid
+91 8891 72 43 72
S6 CSE student
National Institute of Technology , Calicut.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Working directory managment
  2012-03-27 17:10 ` Junio C Hamano
  2012-03-27 21:26   ` Anjib Mulepati
@ 2012-03-28 14:10   ` Anjib Mulepati
  2012-03-28 15:13     ` Junio C Hamano
  2012-03-28 15:41     ` Junio C Hamano
  1 sibling, 2 replies; 11+ messages in thread
From: Anjib Mulepati @ 2012-03-28 14:10 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

So these removed or replaced is done automatically or as I understood we 
do merge and and see conflict and do changes as per necessary?

I was reading Git Community Book and came across following definition
for working directory

The Working Directory

The Git 'working directory' is the directory that holds the current
checkout of the files you are working on. Files in this directory are
often removed or replaced by Git as you switch branches - this is
normal. All your history is stored in the Git Directory; the working
directory is simply a temporary checkout place where you can modify
the files until your next commit.

What does it mean by this " Files in this directory are often removed
or replaced by Git as you switch branches"?

> I think the common terminology for the concept the above describes is "the
> working tree".
>
>> And does working directory is just a directory we get with $pwd ?
> After you clone, you have one directory that contains all the files from
> one specific version in it.  The files may be organized into directory
> hierarchy, but there is a single top-level directory.
>
> That is the "working tree".  When we want to be absolutely clear, we may
> even say "the top of the working tree", even though it may be redundant.
>
> If you are at such a directory, $(pwd) may match it.  If you chdir to a
> subdirectory from there, e.g. "cd Documentation", $(pwd) and the top of
> the working tree will of course disagree.
>
> The files checked out in the working tree represent the contents of the
> version that was checked out, plus modifications you make locally.  When
> you check out a different branch (people coming from svn background may
> say "switch branch", but it is the same thing), the working tree will need
> to represent the contents of the version at the tip of that different
> branch.  If you have a file in the current branch but not in that
> different branch you are checking out, that file has to go away.  If you
> do not have a file in the current branch but not in that different branch
> you are checking out, that file needs to be created in the working tree.
> If the contents of a file is different between your current branch and the
> branch you are checking out, the file in the working tree needs to be
> updated to match that of the branch you are checking out. That is what the
> "... are often removed or replaced" part is talking about.


>
>
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Working directory managment
  2012-03-28 14:10   ` Working directory managment Anjib Mulepati
@ 2012-03-28 15:13     ` Junio C Hamano
  2012-03-28 15:39       ` Anjib Mulepati
  2012-03-28 15:41     ` Junio C Hamano
  1 sibling, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2012-03-28 15:13 UTC (permalink / raw)
  To: Anjib Mulepati; +Cc: git

Anjib Mulepati <anjibcs@hotmail.com> writes:

> What does it mean by this " Files in this directory are often removed
> or replaced by Git as you switch branches"?

Don't you already have an answer from me in the message you are responding
to, which you quoted but perhaps you didn't read?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Working directory managment
  2012-03-28 15:13     ` Junio C Hamano
@ 2012-03-28 15:39       ` Anjib Mulepati
  2012-03-28 16:31         ` jaseem abid
  0 siblings, 1 reply; 11+ messages in thread
From: Anjib Mulepati @ 2012-03-28 15:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

I am sorry if I haven't put my follow up question in proper place. It 
was on top. My question was

So these removed or replaced is done automatically or as I understood we 
do merge and and see conflict and do changes as per necessary?

i don't want to waste someone precious time but I am reading book and 
searching my own in internet to clear my confusion. That is not clear 
all time so that's why I am using this forum. I am reading all replies 
and trying to get basic concept as I go.

Thanks All
Anjib


On 3/28/2012 11:13 AM, Junio C Hamano wrote:
> Anjib Mulepati<anjibcs@hotmail.com>  writes:
>
>> What does it mean by this " Files in this directory are often removed
>> or replaced by Git as you switch branches"?
> Don't you already have an answer from me in the message you are responding
> to, which you quoted but perhaps you didn't read?
>
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Working directory managment
  2012-03-28 14:10   ` Working directory managment Anjib Mulepati
  2012-03-28 15:13     ` Junio C Hamano
@ 2012-03-28 15:41     ` Junio C Hamano
  1 sibling, 0 replies; 11+ messages in thread
From: Junio C Hamano @ 2012-03-28 15:41 UTC (permalink / raw)
  To: Anjib Mulepati; +Cc: git

Anjib Mulepati <anjibcs@hotmail.com> writes:

> I was reading Git Community Book and came across following definition
> for working directory
>
> The Working Directory
>
> The Git 'working directory' is the directory that holds the current
> checkout of the files you are working on. Files in this directory are
> often removed or replaced by Git as you switch branches - this is
> normal. All your history is stored in the Git Directory; the working
> directory is simply a temporary checkout place where you can modify
> the files until your next commit.
>
> What does it mean by this " Files in this directory are often removed
> or replaced by Git as you switch branches"?
>
>> I think the common terminology for the concept the above describes is "the
>> working tree".
>>
>>> And does working directory is just a directory we get with $pwd ?
>> After you clone, you have one directory that contains all the files from
>> one specific version in it.  The files may be organized into directory
>> hierarchy, but there is a single top-level directory.
>>
>> That is the "working tree".  When we want to be absolutely clear, we may
>> even say "the top of the working tree", even though it may be redundant.
>>
>> If you are at such a directory, $(pwd) may match it.  If you chdir to a
>> subdirectory from there, e.g. "cd Documentation", $(pwd) and the top of
>> the working tree will of course disagree.
>>
>> The files checked out in the working tree represent the contents of the
>> version that was checked out, plus modifications you make locally.  When
>> you check out a different branch (people coming from svn background may
>> say "switch branch", but it is the same thing), the working tree will need
>> to represent the contents of the version at the tip of that different
>> branch.  If you have a file in the current branch but not in that
>> different branch you are checking out, that file has to go away.  If you
>> do not have a file in the current branch but not in that different branch
>> you are checking out, that file needs to be created in the working tree.
>> If the contents of a file is different between your current branch and the
>> branch you are checking out, the file in the working tree needs to be
>> updated to match that of the branch you are checking out. That is what the
>> "... are often removed or replaced" part is talking about.
>
> So these removed or replaced is done automatically or as I understood
> we do merge and and see conflict and do changes as per necessary?

Ahhh.

Here is one lesson for you to learn first: "Do not top post".  Your
top-posting made me miss the new questions on these two lines.  In the
above quote, I rearranged them to be the bottom.

By default, we do not attempt the content level merges, as that can let
you screw up your merge and allow you to lose your work in progress, when
you check out another branch.  We do however run tree level merges, so
you will carry your local uncommitted changes in the working tree with you
when you check out a different branch.

When you are just starting, make it a habit to commit the work-in-progress
changes you made for the current branch, even if they are not complete,
before checking out another branch. You do not have to worry about what
would happen to the uncommitted changes that way. When you check out the
branch you left again, you "reset HEAD^" to drop the WIP commit and come
back to the state you had.  E.g.

	$ git checkout -b xyzzy master
        $ edit xyzzy.py ;# new file
        $ git add xyzzy.py
        $ git commit -m 'start working on xyzzy feature'
        $ edit xyzzy.py ;# work more
        ... you got bored and want to work on something else ...
        $ git commit -a -m 'WIP'

        $ git checkout -b frotz master
	... at this point, xyzzy.py is removed from the working tree,
        ... as it did not exist in 'master' hence not in 'frotz'.
	$ edit ... ;# do whatever
        $ git commit -a -m 'done with frotz feature'

        $ git checkout xyzzy ;# back on xyzzy branch
	... working tree matches what is in the WIP commit
	$ git reset HEAD^
        ... working tree remains the same, no more WIP commit
	$ edit xyzzy.py ;# continue from where you left off

Try this while you have "gitk" open and see what is happening by observing
its history display (you would have to refresh it) after "git commit",
"git checkout", and "git reset".

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Working directory managment
  2012-03-28 15:39       ` Anjib Mulepati
@ 2012-03-28 16:31         ` jaseem abid
  0 siblings, 0 replies; 11+ messages in thread
From: jaseem abid @ 2012-03-28 16:31 UTC (permalink / raw)
  To: Anjib Mulepati; +Cc: Junio C Hamano, git

On Wed, Mar 28, 2012 at 9:09 PM, Anjib Mulepati <anjibcs@hotmail.com> wrote:
> I am sorry if I haven't put my follow up question in proper place. It was on
> top. My question was...

With due respect, for simple problems like this the #git IRC channel
on freenode.net is the best place to get answers quick.  Most of the
time you get a solution in a matter of seconds.

-- 
Jaseem Abid
+91 8891 72 43 72
S6 CSE student
National Institute of Technology , Calicut.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-03-28 16:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-27 16:12 Definition of working directory Anjib Mulepati
2012-03-27 17:10 ` Junio C Hamano
2012-03-27 21:26   ` Anjib Mulepati
2012-03-27 23:01     ` Junio C Hamano
2012-03-28  6:06     ` Kevin
2012-03-28  9:40     ` jaseem abid
2012-03-28 14:10   ` Working directory managment Anjib Mulepati
2012-03-28 15:13     ` Junio C Hamano
2012-03-28 15:39       ` Anjib Mulepati
2012-03-28 16:31         ` jaseem abid
2012-03-28 15:41     ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.