LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 04-27-2018, 01:06 PM   #1
bkelly
Member
 
Registered: Jan 2008
Distribution: Centos 7-4
Posts: 205

Rep: Reputation: 13
Git, definition of working directory


On my computer I created a directory named “repo” for repository, and did: git init or maybe some other command. Now I have a series of directories and files from, I presume, the “formal” or “master” repository. (Please feel free to correct that terminology and tell me the right name to use.)

In various tutorials I see references to “working directory” but nothing that outright and clearly states what and where my working directories is/are. To be clear, my concept of a “working directory” is a place where I edit files and save my local copies. No one sees my file changes until I “commit.” If git uses a different terminology, please state so clearly so I can update my vocabulary.

Is my entire directory/file structure my working directory? Can I, Should I, just start editing and saving files. Then when ready I use the command “commit” to send my work to the “formal” or “master” repository so others can see what I did and decide to accept or reject my work
 
Old 04-27-2018, 01:53 PM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Git is more of a mystery to me, and unfortunately I've had to use it more often as of late. Here's what I know, or infer.

When I use "git clone <something>" --> it goes and fetches stuff and typically puts me on the *master* branch

Now if I know I wish a branch, I've been told this by someone, I'll do "git checkout <real-branch-name-they-gave-me> -b<local-name-I-call-the-branch>" -->
It doesn't go and fetch stuff, but if I issue a "git branch" command, it shows me *master* and then my local name and indicates that I'm on that branch. And it gets it correct, even though it doesn't do this immediate fetch.

From there I would do a "git commit" and a "git push", and finally a "git tag"

I've not contended with merging or anything, or had to fetch stuff from another branch. I always tend to do that "all or nothing" approach.

By the way, my understanding is that the commit puts in my new files and changed files. The push formally places it up on the branch.

And a "git tag" will put a label or tag on the branch I'm on, to checkpoint my last changes.

So it's sort of like ClearCase and RCS together, and the verbiage is awkward.
 
Old 04-27-2018, 01:55 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
When I do the "git clone" and it fetches stuff. Typically I have a top of my working tree, however typically the git clone will fetch stuff and establish a one level down, top working directory for whatever it was I fetched. Like if I fetched an ftp client and it was called ftp-client. I'd maybe have /home/<me>/working, and then be in my working tree, issue the clone command and then I'd have (per my example) an ftp-client sub-tree from there. At which point I'd cd into that and then issue all my other git commands.

Note that there is a hidden .git file/directory and may other stuff. I've never looked at them, just noted that they're there.
 
Old 04-27-2018, 02:22 PM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by bkelly View Post
On my computer I created a directory named “repo” for repository, and did: git init or maybe some other command. Now I have a series of directories and files from, I presume, the “formal” or “master” repository. (Please feel free to correct that terminology and tell me the right name to use.)

In various tutorials I see references to “working directory” but nothing that outright and clearly states what and where my working directories is/are. To be clear, my concept of a “working directory” is a place where I edit files and save my local copies. No one sees my file changes until I “commit.” If git uses a different terminology, please state so clearly so I can update my vocabulary.

Is my entire directory/file structure my working directory? Can I, Should I, just start editing and saving files. Then when ready I use the command “commit” to send my work to the “formal” or “master” repository so others can see what I did and decide to accept or reject my work
by default the working directory of a repo is the directory where you issued your 'git init' (unless that directory already contained a config file that tells git explicitely that the working directory is elsewhere).
git's own files should, again by default, all reside in subdirectories of a '.git' directory in the repo's working directory.

a 'git commit' does not yet send the files into the world, unless your local directory also is a git server? i don't know, i do not use git that way.
my usual way is to 'git commit' first, then send it to my remote target with 'git push origin master' or some such.

but, all the info is out there, a few web searches away at most.
that's where i got it from; and i'm very far from being fluent in git.
 
Old 04-27-2018, 02:51 PM   #5
bkelly
Member
 
Registered: Jan 2008
Distribution: Centos 7-4
Posts: 205

Original Poster
Rep: Reputation: 13
ondoho:
Reading your post and thinking more leads me to these conclusions:
When I did a git init, the git utilities created a set of working directories and files on my local computer.

When I use, vi for example, to edit and save my files, git knows nothing about that. Understandable and expected.

When I use git commit I am asking git to make a note of all the files I have changed and record those changes in my local repository, and specifically, within the git directories where git tracks all the changes. Just my local stuff. Joan, in the next cubicle, cannot detect or access my changes.

When I use git push, then my computer sends all my changes out to the formal/central/official repository and git records all my updates there.

Then, one of the git admins (other name for that?) can, if she/he chooses, recognize my code and add it to the formal build process. Then, when a full build it done by anyone my new code is utilized.

As you noted, all the information is available via the various search engines. However, much of it is written with the assumption that the reader is already fully aware of the terminology. Such as, git changes the definition of the verb commit(commit is a verb, it is not a noun) and uses it as a noun. It is also used as a verb within git, so the user must be aware of that overload that I suspect is unique to git.
 
Old 04-27-2018, 03:20 PM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by bkelly View Post
When I did a git init, the git utilities created a set of working directories and files on my local computer.
i don't really understand this statement.
a) the rest of your system does not know or care about git repositories, or its working directories, and is not affected by them.
b) a git repository never goes above its working directory! in other words, if i do this:
Code:
cd ~
mkdir -p bla/bla2
cd bla/bla2
git init
git will never know what's going on in the bla directory, or in ~. only in bla2 (and all subdirectories of that)!

Quote:
When I use, vi for example, to edit and save my files, git knows nothing about that.
only true if it happens outside the git repo, as explained above!!!
 
Old 04-28-2018, 10:42 PM   #7
bkelly
Member
 
Registered: Jan 2008
Distribution: Centos 7-4
Posts: 205

Original Poster
Rep: Reputation: 13
ondoho:
If you don't understand that then I certainly said something wrong or omitted something.

My computer at work is running Centos 7 and it network books. No hard drive. The admin set me up with a working directory. We ran this command

Quote:
mkdir repo
and created a directory by that name. Then we did cd to it and ran a "git" command. I flat out do not remember which command we ran. I am at home now trying to figure some things out. The computer spent quite a while working and as a result I now have a set of directories within /repo with a whole lot of source code, make files, html files, and lots of other stuff.

Given that I have all this, is/are all the directories and space within my /repo directory my "working directory"?
 
Old 04-29-2018, 09:18 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
ok, first of all there really isn't much to discuss if you do not remember the exact commands issued.
have you tried entering
Code:
history
???

then there seems to be a misinterpretation/misunderstanding about the term "working directory".
that can mean all sorts of things; for the user, for a git repo, etc.
if you use a shell and command line, the "present working directory" simply means the directory you currently are in.
you can check with
Code:
pwd
for a git repo, it has a more specific meaning; but that does not have anything to do with your shell's working directory.

look, all htese things are really better explained by reading some real documentation, not my ramblings.
just learn to create good search terms, i'm sure "git working directory" will return something meaningful.
 
Old 04-29-2018, 01:01 PM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,996

Rep: Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338Reputation: 7338
git is a version control system. It has two main parts: a database containing the history of all the files and their versions which are put/stored in a directory and in its subdirs recursively. This database is named repository.
The other important part is a workspace or working tree where you can see a given state of your files/dirs - constructed from the repository. You can also work on these files within that workspace and git will [be able to] store/follow those changes in the repository.


https://git-scm.com/docs/gitglossary
https://juristr.com/blog/2013/04/git-explained/

When you check man git init you will see it creates a new, empty repository.

Last edited by pan64; 04-29-2018 at 01:05 PM.
 
Old 04-30-2018, 05:08 PM   #10
bkelly
Member
 
Registered: Jan 2008
Distribution: Centos 7-4
Posts: 205

Original Poster
Rep: Reputation: 13
pan64: A possible update to your siggie:
Quote:
A program will never do what you wish but what was implemented!
and the suggestion

Quote:
Programs always do what was implemented, but, with heroic effort, will sometimes do what was intended.
 
Old 05-04-2018, 09:20 PM   #11
johnmike88
LQ Newbie
 
Registered: May 2018
Posts: 2

Rep: Reputation: 0
Great, hope to see that it will get sorted out!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
git - problem with EOL formats working with git svn eantoranz Programming 2 06-20-2015 09:50 AM
git clone: Git Protocol not working SnH Linux - Newbie 3 05-23-2013 02:29 AM
[SOLVED] set directory structure in git xeon123 Linux - Newbie 1 06-24-2011 07:15 PM
[SOLVED] Can't install Git repo (I don't git git ) Nemus Linux - Software 3 05-20-2011 02:09 PM
Samba - Share definition on a folder under a home directory craig467 Linux - Software 9 06-07-2005 03:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 12:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration