Re: Git documentation on branching.
On Mon, 10 Apr 2017 12:24:47 +0200 Samuel Åslundwrote: [...] > >> One feature with "git branch xyz" and "git checkout xyz" that is > >> rather obvious if you know them but bit me a little since I did > >> not, is that uncommitted work in progress is not affected or saved > >> when switching between branches. > > [...] > > But neither is uncommitted work saved anywhere when you do > > `svn switch` in Subversion which is analogous to `git checkout`. > > > > While I do know quite many people expect Git to somehow "preserve" > > their work when switching branches without having them do anything, > > I wonder what in Subversion workflow makes you think Git should have > > had the behaviour you expected? > > svn switch is heavy, thus I usually checked out a new branch in > another directory. So probably not the Subversion workflow but rather > _my_ workflow in Subversion. Yes. The equivalent thing with Git would be using its `git worktree` subcommand (which is a stock subcommand since some time, and previously was available in the form of an external script). The said command basically creates another "checkout" -- a working tree and a separate index -- linked to the original repository. You can have any number of such separate work trees, and what's checked out in them is completely irrelevant to the repository itself (which only keeps commits and the data they refer to). Note that since `git worktree` was (is?) sort of a clever hack not originally envisioned as one of "stock" workflows, its insufficiently covered by the documentation. And while it indeed may be useful -- sometimes it's ineed convenient to have two versions of the same codebase to be checked out side-by-side, -- I'd warn you against rushing for using `git worktree` as it appears to support what you did with Subversion: there is another approach to support your mindset which I'll explain in a moment. > Either way, your comment about peoples expectations was what I wanted > to address. Expectation management is the responsibility of the > documentation, right? It's hard to tell -- as Ævar Arnfjörð pointed out: there are two kinds of documentation: manuals and books / introductory courses. As was shown to you, the manual page on `git checkout` explains what it does. Whether that's clear right away to any newcomer, I cannot say. Probably not, but if we'd turn that manual page to a book it will lose its original meaning of being dry and to the point. I have that problem with manual pages all the time: quite often they are most useful on some Nth re-reading, where you approach them with certain working knowledge under your belt -- and suddenly certain things you read there "click" in your head; you did read them before but your mind just skimmed over them while having the impression of grasping the material. > I find it quite reasonable to choose whether to stash the work in > progress myself before checking out another branch, but since I did > not expect to need to do that I didn't. > > I think that what made me expect Git to handle my uncommitted work is > how the documentation talks about making it easy to switch between > working on different features, most of the time I do not feel > comfortable checking in when a feature is in a broken state and > interruptions for quick fixes usually comes in those situations. That's more complicated that it sounds. Consider the following things (in no particular order). Sometimes "carrying your uncommitted work over" to another state of the codebase is precisely what you'd want to happen, and that's what `git checkout` does for your. It even has a specual "I DO REALLY WANT IT TO HAPPEN" switch, "-m", which makes that command to try to merge your local modifications into what is about to be checked out if otherwise your changes would be in conflict with that state. What's with untracked files? Sometimes they should be considered part of the work to be saved away before checking out another state, and sometimes not (`git stash` has a special switch, "-u" to make it stash untracked stuff as well). What would be the default mode? Think of it, and supposedly you'll come to a conclusion that either mode Git could implement would alienate some group of folks. ;-) Now let's consider the most interesting bit. People switching from a non-distributed VC system are inherently and subconsciously afraid of committing anything which "is not ready". This is definitely a correct mindset with Subversion (which, IIUC, still does not implement shelving it considered for a long time) but not with Git. Here, it's absolutely OK to lump together all the stuff you're currently working it by `git add`-ing them, `git commit` it all -- usually putting an informal "WIP" prefix in the front of the commit message to indicate it's work in progress -- and then switch away to another branch. When back, you just to `git reset HEAD~1` to move your checked out branch one commit back and
Re: Git documentation on branching.
On Mon, Apr 10, 2017 at 12:45 PM, Samuel Åslundwrote: > On 17/4/10 12:21, Ævar Arnfjörð Bjarmason wrote: >> >> On Mon, Apr 10, 2017 at 8:56 AM, Samuel Åslund >> wrote: >>> >>> Hi all. >>> >>> I just started playing around with branching in git. >>> I have been using it more or less as Subversion until now. >>> >>> One feature with "git branch xyz" and "git checkout xyz" that is rather >>> obvious if you know them but bit me a little since I did not, is that >>> uncommitted work in progress is not affected or saved when switching >>> between >>> branches. Thus I cleaned up the directory when working with the branch >>> and >>> now I'm trying to find a stash where I hopefully have a copy of those >>> files. >>> >>> Would it be possible to add something in the documentation to warn others >>> that uncommitted work is not saved or affected by branching? >> >> >> The main UI in git for switching branches is "git checkout", and it's >> mentioned in the second paragraph of the documentation: >> >> "[when switching branches] local modifications to the files in the >> working tree are kept, so that they can be committed to the >> .". >> >> Did you read this and find it unclear, and if so can you elaborate on >> what the confusion was, maybe we can fix the docs with that in mind? >> >> Or did you read some entirely different docs (what docs?) where we're >> perhaps not mentioning this as prominently? > > > No, I did not read the git checkout manpage. > When I googled "git branch" I got the two pages mentioned below and this > one: > Git - Basic Branching and Merging > https://git-scm.com/.../Git-Branching-Basic-Branching-and-Mer... This list doesn't maintain that book, it looks like the right place to file bugs & improvement suggestions in it is https://github.com/progit/progit2 It might be an issue with the git-scm site though that issues in the book aren't funneled there instead of here. How did you go from noticing an issue in the book to contacting this mailing list? Maybe we need to update some page involved in that. > I find that mostly manpages require some context before they are useful so I > go for the more wordy pages when trying to get my head around something new. > Neither of the three top-hits on google included the local modifications > comment where I noticed it. An actual search for that string right now does > not find anything either. Yeah but unfortunately we can do little about that stuff, we just maintain the man pages. > The comment you refer to in the git checkout man-page is probably enough > heads-up for someone who knows git reasonably well, I do not know if it > would have made me realize exactly how the feature works. > I'm not even sure I know how "local modifications" is defined in Git > terminology, does it include "(un)staged changes", and or untracked files? Maybe we should say "uncommitted modifications" there. I think starting to talk about staged & unstaged might just invite similar confusion. It's hard to say anything in these docs without being inaccurate or losing the audience :( > Thanks for the attention. > > >>> The first two hits on my google search was very informative about >>> branching >>> but I did not see that specific nugget of information (I might have been >>> careless reading, but if I did not see it others will probably also miss >>> it). >>> >>> Git - git-branch Documentation >>> https://git-scm.com/docs/git-branch >>> >>> Git - Branches in a Nutshell >>> https://git-scm.com/book/.../Git-Branching-Branches-in-a-Nutsh... >>> >>> This is my first try to contribute to the Git community, I hope it will >>> be >>> useful to somebody. >>> >>> Regards, >>> //Samuel > >
Re: Git documentation on branching.
On 17/4/10 12:21, Ævar Arnfjörð Bjarmason wrote: On Mon, Apr 10, 2017 at 8:56 AM, Samuel Åslundwrote: Hi all. I just started playing around with branching in git. I have been using it more or less as Subversion until now. One feature with "git branch xyz" and "git checkout xyz" that is rather obvious if you know them but bit me a little since I did not, is that uncommitted work in progress is not affected or saved when switching between branches. Thus I cleaned up the directory when working with the branch and now I'm trying to find a stash where I hopefully have a copy of those files. Would it be possible to add something in the documentation to warn others that uncommitted work is not saved or affected by branching? The main UI in git for switching branches is "git checkout", and it's mentioned in the second paragraph of the documentation: "[when switching branches] local modifications to the files in the working tree are kept, so that they can be committed to the .". Did you read this and find it unclear, and if so can you elaborate on what the confusion was, maybe we can fix the docs with that in mind? Or did you read some entirely different docs (what docs?) where we're perhaps not mentioning this as prominently? No, I did not read the git checkout manpage. When I googled "git branch" I got the two pages mentioned below and this one: Git - Basic Branching and Merging https://git-scm.com/.../Git-Branching-Basic-Branching-and-Mer... I find that mostly manpages require some context before they are useful so I go for the more wordy pages when trying to get my head around something new. Neither of the three top-hits on google included the local modifications comment where I noticed it. An actual search for that string right now does not find anything either. The comment you refer to in the git checkout man-page is probably enough heads-up for someone who knows git reasonably well, I do not know if it would have made me realize exactly how the feature works. I'm not even sure I know how "local modifications" is defined in Git terminology, does it include "(un)staged changes", and or untracked files? Thanks for the attention. The first two hits on my google search was very informative about branching but I did not see that specific nugget of information (I might have been careless reading, but if I did not see it others will probably also miss it). Git - git-branch Documentation https://git-scm.com/docs/git-branch Git - Branches in a Nutshell https://git-scm.com/book/.../Git-Branching-Branches-in-a-Nutsh... This is my first try to contribute to the Git community, I hope it will be useful to somebody. Regards, //Samuel
Re: Git documentation on branching.
On Mon, Apr 10, 2017 at 8:56 AM, Samuel Åslundwrote: > Hi all. > > I just started playing around with branching in git. > I have been using it more or less as Subversion until now. > > One feature with "git branch xyz" and "git checkout xyz" that is rather > obvious if you know them but bit me a little since I did not, is that > uncommitted work in progress is not affected or saved when switching between > branches. Thus I cleaned up the directory when working with the branch and > now I'm trying to find a stash where I hopefully have a copy of those files. > > Would it be possible to add something in the documentation to warn others > that uncommitted work is not saved or affected by branching? The main UI in git for switching branches is "git checkout", and it's mentioned in the second paragraph of the documentation: "[when switching branches] local modifications to the files in the working tree are kept, so that they can be committed to the .". Did you read this and find it unclear, and if so can you elaborate on what the confusion was, maybe we can fix the docs with that in mind? Or did you read some entirely different docs (what docs?) where we're perhaps not mentioning this as prominently? > The first two hits on my google search was very informative about branching > but I did not see that specific nugget of information (I might have been > careless reading, but if I did not see it others will probably also miss > it). > > Git - git-branch Documentation > https://git-scm.com/docs/git-branch > > Git - Branches in a Nutshell > https://git-scm.com/book/.../Git-Branching-Branches-in-a-Nutsh... > > This is my first try to contribute to the Git community, I hope it will be > useful to somebody. > > Regards, > //Samuel
Re: Git documentation on branching.
On Mon, 10 Apr 2017 08:56:30 +0200 Samuel Åslundwrote: > I just started playing around with branching in git. > I have been using it more or less as Subversion until now. > > One feature with "git branch xyz" and "git checkout xyz" that is > rather obvious if you know them but bit me a little since I did not, > is that uncommitted work in progress is not affected or saved when > switching between branches. [...] But neither is uncommitted work saved anywhere when you do `svn switch` in Subversion which is analogous to `git checkout`. While I do know quite many people expect Git to somehow "preserve" their work when switching branches without having them do anything, I wonder what in Subversion workflow makes you think Git should have had the behaviour you expected?
Git documentation on branching.
Hi all. I just started playing around with branching in git. I have been using it more or less as Subversion until now. One feature with "git branch xyz" and "git checkout xyz" that is rather obvious if you know them but bit me a little since I did not, is that uncommitted work in progress is not affected or saved when switching between branches. Thus I cleaned up the directory when working with the branch and now I'm trying to find a stash where I hopefully have a copy of those files. Would it be possible to add something in the documentation to warn others that uncommitted work is not saved or affected by branching? The first two hits on my google search was very informative about branching but I did not see that specific nugget of information (I might have been careless reading, but if I did not see it others will probably also miss it). Git - git-branch Documentation https://git-scm.com/docs/git-branch Git - Branches in a Nutshell https://git-scm.com/book/.../Git-Branching-Branches-in-a-Nutsh... This is my first try to contribute to the Git community, I hope it will be useful to somebody. Regards, //Samuel