9 ms·
While I don't think git couldn't be improved, especially in terms of ux, I do feel like losing staging area altogether is quite significant sacrifice, like thro
by zokier 10y ago
While I don't think git couldn't be improved, especially in terms of ux, I do feel like losing staging area altogether is quite significant sacrifice, like throwing the baby with the bathwater. The ability to build up and massage the commit in staging is really powerful method, and I think it makes git actually easier to learn once you get beyond the initial hump due its interactive nature.
- rspeer 10y agoAside from selective commits (which they provide a different interface for), what do you use the staging area for?
- ktt 10y agoNot the parent but I'm using it to stage sections of the file and then revert everything that is not staged. For example all logging statements. Or use staging as a mini commit. It's sometimes easier to look at the diff and stage what you consider to be working code without introducing commits. That of course could also be done with committing and then squashing but that's more work :)
- krupan 10y agoor committing and amending that commit, which is really no extra work
- indspenceable 10y agoA quick peruse doesn't show that there's a way to only commit certain parts of a file (like you can do in vanilla git via `git add --patch`)
- joshka 10y ago"There's also a p/partial flag that allows you to interactively select segments of files to commit." http://gitless.com/#gl-commit http://gitless.com/#gl-commit But looking at it, this seems like it would strongly couple the decision to include a part of a file with the commit process rather than something that I can be thinking about as I write the change. I think I'd likely find that irritating.
- sanderjd 10y agoThis is so tautological that it might sound sarcastic, but I frequently use it as a staging area before committing. Both for whole- and partial-file changes. This seems easier and more sensible than amending commits to me. When I use other version control systems that don't have this feature (which is maybe all of them?), I miss it.
- acemarke 10y agoThat's kinda the point, though. I don't want to run a single command to both define and complete the commit. I want to be able to do it in steps. Review my modified files, pick and choose what's staged, maybe make some more edits, stage those, double-check the staged diffs, verify the commit has what I want, and _then_ hit the button.
- krupan 10y agoYou make it sound like a commit is some final immutable set-in-stone thing and so you need staging area. Commits are only "set in stone" after you share (push) them with others.
- acemarke 10y agoYou're still missing my point. My preferred workflow is to iteratively put together the pieces I want, and only hit the "commit" button when I'm pretty sure I've got it crafted the way I want. Sure, I _can_ rebase, amend, and rewrite commits after creating them, assuming I haven't pushed them yet, but I'd much rather do it _before_ the commit is created. At first glance, this "gitless" tool doesn't seem to really support that workflow.
- derefr 10y agoWhy, though? What's the difference between a staging area that you convert into a commit, and an initially-empty commit that acts as a staging area, that you "commit" by just not modifying it any more, and instead creating a new empty commit (new staging area) to work in? They're bijective mappings of the same data, with the same actions triggered at the same points in a workflow. The only difference is what you label the actions. To go further: how do you feel if you think of all your un-pushed commits as simply "a chain of staging areas"? What if "committing" was something that happened at git-push time, and until then, you just created staging-area after staging-area and populated them with patch-chunks? Because this would also be a bijective mapping, involving the same actions in the same places.
- 10y ago
- FullyFunctional 10y agoWhy is that important given that you can do exactly the same with a commit in the local tree? I haven't read the paper, but the last paragraph in the article makes me a little sad. Then again, there were hardly any progress that wasn't met with significant resistance initially. (EDIT: typos)
- Mithaldu 10y agoIt comes down to levels of "written in stone"-ness, for lack of better words. There's a hierarchy of how much thought and effort change requires at various levels, starting at requiring no additional thought, to requiring considerable thought, and maybe even coordination with others: - changes on hdd - changes in staging area - changes in commit - changes in commit that came before a recent commit - changes in pushed commit I'm not entirely sure about the following, and i think it merits more thought, but here's my current state of mind about it: Technically you could do the same as the staging area by forcing the user to create a new, empty, but named commit when they decide they're done with the last one, and have all the current staging-affecting commands affect the last commit instead. However, for one, i think it may be easier to mess up and lose data unexpectedly when workign that way, and for the other, putting down a name for a commit when you're not even sure what it's gonna be may be an awkward way of working. Lastly, you'd also need to implement "empty" commits. I'm not sure how useful/easy that would be with git.
- icebraining 10y agoEmpty commits already are supported (see --allow-empty). And you can rename that commit at will using --amend, so the first name could simply be a placeholder - like "staging" :)
- dangom 10y agoIt's important to note that gitless aims to be a porcelain on top of git. That means git stash isn't going anywhere: both systems can operate together seamlessly on a same repository.
- krupan 10y agoI disagree. Forcing a weird pseudo commit, with its own unique set of commands for interacting with it, into the basic workflow is not the right approach. Without an index, beginners can just commit. As people get more adventurous, they can learn commands like commit --amend and rebase --interactive to build up and massage their commits.
- spinningarrow 10y agoSo what would be the workflow for committing (and perhaps pushing) partial changes in that case? Say you've made a lot of changes and they don't all belong together.
- gkya 10y agoIf I needed to do a partial commit I'd record the diff ("git diff > big.patch" or git stash), clean the repository, and build the patch to be committed manually picking from the recorded diff, test thoroughly and commit only when the patch is coherent (ie tests pass, compiles and runs). Then I'd just apply the rest of the patch to continue working. AFAIK the git model (git add [-p]) and history editing makes it very easy and probable to produce incoherent commits which when checked out does not compile, test all-OK or behave wrong. I use CVS for my personal stuff for various reasons but even if I used git I'd do it like this. P.S. if your granularity is in the level if files and not individual hunks of the overall patch then you can just "cvs/git commit files..." easily but still, it'll go in untested and you may have forgotten a change that was required in order to make the commited patch valid and coherent.
- rtb 10y agoI used to do that with SVN. What a pain in the ass. Git's version is miles better.
- bicolao 10y agoDo partial commits. Run a new interactive rebase session, set "edit" to all those commits so you can test out individual ones and fix up some more if needed. Basically the same outcome, but less manual diff editing.
- ngoldbaum 10y agoMercurial gets around this issue (without having a staging area) by providing an interface for interactively committing files or subsets of files via "hg commit --interactive"
- infogulch 10y agoI did not know that existed. Thank you for informing me.
- ngoldbaum 10y agoThere is also a very nice curses interface for interactive chunk selection. To turn it on set interface.chunkselector=curses under the ui section in your .hgrc.
- Mithaldu 10y agoGit has the same with `git add -p`, and if you're operating on a gui system, git-gui is excellent.
- lambda 10y agoThe staging area is a lot more useful than what you can do with an interactive commit, since it persists between operations. You can use it to accumulate changes that are "done" while you continue to experiment with some other changes on top, even if you're planning on committing the whole thing at once, and if you wind up not liking your new changes, revert to what you had in the staging area; or you can realize what you're working on will be easier to finish as two commits, stage part of it, stash the other part, finish the part that was staged and commit it, then apply the stashed part and finish that too. This is a lot more than you get with just a single interactive commit operation. You could use a commit for this purpose, and continually amend or revert this commit, but in terms of UI, it's helpful to have a set of operations specifically for moving things in and out of the staging area that's different than what you do for manipulating commits on general.
- Too 10y agoThe whole problem with the staging area in git is that it persists between operations. Why would you want to add things piece by piece and not commit them? If they are done enough to be added they are done enough to be committed and if they are not you keep working on them together with all other unfinished files. Once you actually are ready to commit you can choose which files that are in fact ready.
- toomim 10y agoDid you read the gitless instructions? [1] You get the same functionality as a staging area by keeping a list of all the files you want to commit, and then run once: gl commit -o file1 file2 file3 file4 [1] http://gitless.com http://gitless.com
- dajohnson89 10y agoand if my change affects two hundred files, across dozens of directories?
- toomim 10y agoYou find it hard to create a list? Here's an example of making a staging file: echo file1 > staging # e.g. git add file1 echo dir2/file2 >> staging # e.g. git add dir2/file2 echo dir3/file1 >> staging echo dir3/file5 >> staging echo dir4/dir9/dir394/file384 >> staging And committing the file: eval "$(echo gl commit -o `cat staging`)" # e.g. git commit
- to3m 10y agoDude.
- jdmichal 10y agoCongrats. You just recreated a bad implementation of the staging area in a text file.
- toomim 10y agoCongrats, you got the joke! ;) A staging area is just a list of things to commit. There are many ways to make lists. I personally use emacs because direct manipulation rocks. Complaining about a change in one way to make lists is silly—gitless introduces much more powerful basic mechanisms like uncommitted branching, and lists belong on top of these more powerful basic features; not underneath like in the traditional porcelain.
- gkya 10y agoHow do you test what is in the staging area as a subset of all the changes fir consistency (i.e. can you be sure when committed and later checked out it will be a coherent stage of the project history that will test compile and run okay)?
- deleted 10y ago[deleted]
- morsch 10y agoCommit (don't push), stash remaining changed files, compile and run your tests. If anything goes wrong, either fix it and commit --amend, or reset --soft HEAD~ to return the commit to the staging area and fix from there. Unstash as required.
- slavik81 10y agoPerhaps the worst piece of UX in all of git is the naming of the staging area. The docs and arguments use 'index', 'cache' and 'staging' all to refer to the same thing. The names 'index' and 'cache' are awful, but the inconsistency is unforgivable.
- nerdponx 10y agoI still have to check myself when I see references to the "work tree"
- Mithaldu 10y agoWhile the staging area could use some UX improvements, it is the most important part of git and proper usage of it fosters good history clarity and code quality For that reason i agree strongly. Any attempt to improve git that does not move the staging area more to being the default way of operating is misguided at the code.
- deleted 10y ago[deleted]