* [noob] is this normal behavior @ 2017-05-09 13:02 Harry Putnam 2017-05-09 20:25 ` Igor Djordjevic 0 siblings, 1 reply; 3+ messages in thread From: Harry Putnam @ 2017-05-09 13:02 UTC (permalink / raw) To: git Setup: Running openindiana (hipster) a solaris 11 open source branch git 2.12.2 I've recently moved from mercurial to git mainly because git appears to receive the most development and the heaviest use. I'm using git with hold over behavior developed from my time using cvs long ago. I keep a hierarchy of directories and files that mirrors the structure on the OS where git is installed [just where ever tracked files are located on OS] not the entire structure. I keep a git repo on the same OS that is created by rsyncing the BUFFERED hierarchy into a git repo Many of the BUFFERED files are symlinked to there places in the OS Some are not because certain files being symlinked seemed to cause permissions type problems on the OS. In those cases they are periodically copied to the BUFFER hierarchy So, not to get too tangled up in explaining my setup... tracked files change in the buffer area or new files are created there. Periodically I rsync the files in BUFFER over the files in git repo And record the changes thru normal git operations git status git add (when needed) git commit ,---- | Aside: | While I would welcome comments or suggestions about using a setup like | this, that is not the subject of this post. `---- This is my most recent attempt at learning and using git but I have done a few tries before. I'm noticing behavior I do not recall seeing in earlier attempts. rsyncing the buffer over the git repo is now producing a result where `git status' shows any changed or added files as modified or new but all need to be added before a commit can take place, not just the new ones. Shouldn't files that changed but are already being tracked just show up as modified and not need adding? That is, if I have the file ~/.bashrc, which is really a symlink to BUFFER/OS/export/home/reader/.bashrc And is tracked in git repo as REPO/OS/export/home/reader/.bashrc When; BUFFER/OS/export/home/reader/.bashrc is edited. Then rsynced like below: BUFFER <root of rsync is here> /OS/export/home/reader/.bashrc over GITREPO <root of rsync> /OS/export/home/reader.bashrc Thereby changing the repo file in place Since that file is already being tracked; shouldn't `git status' show that file as modified but ready to be committed instead of a file that is modified but needs to be added before a commit can happen? Another side of this is that a `git diff FILE' only works before an `git add .' operation is done. That is, if I run `git diff FILE' AFTER `git add' .. no diff is reported, even though it is not committed yet. So, for example: if I'm committing and in the vi buffer of the commit and want to see a diff of FILE to aid my log notes. git diff FILE will report nothing whatever. Is that expected behavior? ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [noob] is this normal behavior 2017-05-09 13:02 [noob] is this normal behavior Harry Putnam @ 2017-05-09 20:25 ` Igor Djordjevic 2017-05-10 17:27 ` Harry Putnam 0 siblings, 1 reply; 3+ messages in thread From: Igor Djordjevic @ 2017-05-09 20:25 UTC (permalink / raw) To: Harry Putnam, git Hi Harry, Both behaviours you report are normal, specifically: On 09/05/2017 15:02, Harry Putnam wrote: > Shouldn't files that changed but are already being tracked just show > up as modified and not need adding? > ... > Since that file is already being tracked; shouldn't `git status' show > that file as modified but ready to be committed instead of a file that > is modified but needs to be added before a commit can happen? No, it shouldn`t - even though the file you`ve modified is already being tracked, it doesn`t have to mean you want the modification inside your very next commit, and Git doesn`t force that upon you. That is where index (or "staging area") comes in handy, allowing you to `git add` only the changes you actually want to commit now, leaving the others for later decision. You don`t even have to add all the modifications inside the single file at once, for example by using `git add --patch`[1] you can select just some of the them, fine tuning what gets committed and when. With some precaution/steps needed not to commit broken project states by accident, and some discipline not to overdo it, this allows you to fully focus on the actual work you do, making logically unrelated changes in place as you see fit, on the go, and only later organizing them into logically grouped commits, through diligent use of `git add`. > Another side of this is that a `git diff FILE' only works before an > `git add .' operation is done. > > That is, if I run `git diff FILE' AFTER `git add' .. no diff is > reported, even though it is not committed yet. > > So, for example: if I'm committing and in the vi buffer of the commit > and want to see a diff of FILE to aid my log notes. > > git diff FILE will report nothing whatever. > > Is that expected behavior? Yes, that is as expected - in the form you`ve given, `git diff` shows the differences between your working tree and index (staging area), so only changes you haven`t added yet. Once you `git add` the changes from the working to the index, there are no more differences to show, so no diff is produced. If you want to see the added changes, what will be included in the commit if you make it, you can use `git diff --cached`, as per git-diff[2] documentation (--staged can also be used instead, being a synonym for --cached, but maybe easier to remember, relating it to "staging area"). That option shows differences between the staging area (index) and the specific commit - with none provided, it implies your currently checked-out position (referred to as HEAD), usually being your latest/previous commit, which is exactly what you`re interested in. As a side note, if you think you don`t need it, you can skip staging area and commit all the modifications/deletions without a need of adding them first by using `git commit --all`, as per git-commit[3] documentation. Just pay attention that untracked files are not affected, you still need to add them first to tell Git to start tracking them, including them in the next commit, but that seems to align nicely with your expectations already. I personally find the staging area to be one of the greatest Git possibilities, but I do understand beginners getting confused by it, as admittedly I once was myself. In the end, you may want to ask questions like this on Git users mailing list[4] on Google Groups, being a a nice place for beginners to get answers to their concerns. [1] https://git-scm.com/docs/git-add [2] https://git-scm.com/docs/git-diff [3] https://git-scm.com/docs/git-commit [4] https://groups.google.com/forum/?fromgroups#!forum/git-users Regards, Buga ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [noob] is this normal behavior 2017-05-09 20:25 ` Igor Djordjevic @ 2017-05-10 17:27 ` Harry Putnam 0 siblings, 0 replies; 3+ messages in thread From: Harry Putnam @ 2017-05-10 17:27 UTC (permalink / raw) To: git Igor Djordjevic <igor.d.djordjevic@gmail.com> writes: [...] snipped detailed reply [To Anyone who lands here on a search: Please read Igor D's full answer in this thread... ] > Just pay attention that untracked files are not affected, you still > need to add them first to tell Git to start tracking them, including > them in the next commit, but that seems to align nicely with your > expectations already. > > I personally find the staging area to be one of the greatest Git > possibilities, but I do understand beginners getting confused by it, > as admittedly I once was myself. Thank you sir for such a full and complete answer. Adds to by understanding in a big way. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-10 17:27 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-05-09 13:02 [noob] is this normal behavior Harry Putnam 2017-05-09 20:25 ` Igor Djordjevic 2017-05-10 17:27 ` Harry Putnam
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.