4 ms·
Most of this stuff can be done with aliases. git stage git config alias.stage '!f () { if (( $# > 0 )); then git add -- "$@"; else git add -u; fi }; f'
by eridius 15y ago
Most of this stuff can be done with aliases.
git stage
git config alias.stage '!f () { if (( $# > 0 )); then git add -- "$@"; else git add -u; fi }; f'
git unstage
git config alias.unstage 'reset --'
git undo is too ill-defind to actually implement. Sounds like the author wants it to be `git reset --hard HEAD`, but it's far more dangerous doing that while termed `git undo` than it is while termed `git reset --hard HEAD`, because people will have unrealistic expectations of what it does.
What's wrong with `git rm`? Here's a hint: you don't need to use it. Most people I know just delete the files however they want, and then run something like `git add -u` to pick up the deletions. That's exactly what the author is suggesting, but that's what people do today, so I don't see the issue.
As for git status, there's already a --short (or -s) flag that gives a very terse output. I personally use that all the time with an alias `git config alias.st 'status -sb'`.
Automatic setup? Put that info in the global config file. If git had to prompt for it, it would naturally place that info in the per-repo config file (absolutely would not make sense to automatically modify the global one), and it would be more confusing to users to be constantly re-prompted for name/email (because they switched repos). I don't see the problem with just telling new users to set up name/email globally, which every git tutorial I've seen does.
git switch
git config alias.switch checkout
For git diff confusion, just use aliases for different commands. Do not make me type STAGE, that's no friendlier to users. I personally run with the following two aliases:
git config alias.staged 'diff --cached'
git config alias.unstaged 'diff'
though I rarely use the `git unstaged` command. I also have
git config alias.both 'diff HEAD'
though I never use this one. Perhaps other names can be chosen that the author likes better.
The bit about deleting branches is misguided. `git remote` is a command that has sub-commands. `git branch` isn't. I understand that the author thinks having two styles of commands is weird, but there's not really a good alternative. Commands like `git remote` that have sub-commands would not work very well at all in the switch model (for a pathalogical example try to imagine what `git svn` would look like this way), and switch-based commands, which is most commands in git (and most commands in UNIX in general) would not do well in the sub-command model.
- mintplant 15y agoPer "git undo", what about something like: git rewind git rewind FILE git rewind --revision=REVISION git rewind FILE --revision=REVISION We already have the "fast forward" metaphor.
- eridius 15y agoInteresting idea, though I don't get the need for the --revision flag in your example. It's already pretty easy to tell the difference between revisions and files. If you want to call it unwind, why not just make that an alias for reset? git config alias.rewind reset
- deleted 15y ago[deleted]
- deleted 15y ago[deleted]
- mintplant 15y agoAh, okay. Wasn't sure how well the system could differentiate the two. You could always make aliases for things, but the point of the article seems to be addressing the problem of people new to git, who likely won't go about setting such aliases, let alone know they have that capability. And that's a problem I can sympathize with: I'm a programmer on an FRC (http://www.usfirst.org/ http://www.usfirst.org/) team, and this year, we finally convinced everyone to make the jump from a thousand USB sticks to a git repo. We've held a workshop on it and have distributed various tutorials -- GitHub's have been particularly invaluable -- but there are still issues every now and again. Some seem to only have "push button, receive outcome" understanding of how it works, memorizing the commands for cloning, pushing, and pulling and then blindly repeating them into the console, without a full knowledge of what's going on. If some of the more "advanced" syntax was a bit more human from the get-go, then it might be helpful in softening the learning curve.
- jamesgeck0 15y ago>Automatic setup? Put that info in the global config file. If git had to prompt for it, it would naturally place that info in the per-repo config file (absolutely would not make sense to automatically modify the global one) You're thinking of implementation details, but prompting for and placing the info into ~/.gitconfig is what a newbie git user almost always wants. What's wrong with doing this?
- eridius 15y agoBecause it will completely screw with anyone who actually wants it in the per-repo config file. If I'm new to git, and my first usage is on a sample project, and git prompts me then I'll put in my personal contact information. But then if I go and start working on my company's git project, it will never prompt me again and I'll accidentally be committing company code under my personal email address. And I would be perfectly justified in blaming git's faulty user interface for letting that happen. At least if I set the config myself I _know_ I'm placing it in the global config file.
- jamesgeck0 15y agoYour use case makes sense, but 1) Git's current initial setup UI would not prevent the user from making that mistake. It might make them feel stupid when they remember, but that's not the same thing as usability. The commit interface displays your identity and might throw up a red light. 2) Having made this mistake, a new user isn't going to remember the "git config" or "git commit --amend" commands they copied when prompted (if they remember entering them at all; I didn't remember exactly how initial setup worked). They're going to have to go look them up anyway. 3) Every user of Git will have a global username/email. Not every user will set them on a per-repo basis. I guess I'm wondering why Git inconveniences everyone in deference to the less common use case.
- eridius 15y agoIn the common case, a lack of username/email actually indicates a configuration error. Blindly offering to set username/email may cause people to "fix" their config by re-setting username/email when in fact the lack of this is indicative of some other issue. Sure, _everybody_ sets up git once, but on the other hand, everybody sets up git _once_. The common use case is, by far, running with git already configured.