Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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.
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.
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.
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!!!
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"?
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.