But can it also undo the undo? Anyway, shouldn't git just come with a "undo" command?
How to undo almost anything with Git (2015)
61–70 of 84 posts
Re: How to undo almost anything with Git (2015)
#62git-extras has a tool called `git undo`. It's just a fancy wrapper around `git reset --soft HEAD` though.
Intellij has a "shelve" command, I decided to stick with "git stash". Magit has the "i", that does "ignore" but also cleans up already committed files, something like "git rm -r --cached ."
Re: How to undo almost anything with Git (2015)
#63Also worth noting: you can abort and undo many kinds of in-progress operations with “git —abort”. Works for merge, rebase, and a few other things, and can seriously save your bacon when you do a “git merge ” and are suddenly confronted with a bazillion merge conflicts. Also, if you’re in a panic because something went screwy, check “git status” and read every line carefully. status tells you a lot more than you might…
> check “git status” and read every line carefully. Seconded, but I'd go even further. Run and read git status before and after running any git command until you get comfortable enough with git to where you can predict the output without running it. Additionally you can go get git prompt[1] installed so you always know your git status at a glance. Saves a lot of typing in any case. As a last suggestion I'd say go rea…
Unfortunately so many people put that aside and never read it, and then come back to me a few weeks later because they messed everything up again, and still do not understand what I mean with "index".
Git is very powerful but a bit awkward, so I consider knowing the underlying concepts necessary to use it properly.
Re: How to undo almost anything with Git (2015)
#64For several months now I've been wondering how to get rid of a 700 MB data file that was accidentally committed to our shared git repo. Now everyone has it, and a clean pull takes forever. Appreciate any thoughts.
Re: How to undo almost anything with Git (2015)
#65Also worth noting: you can abort and undo many kinds of in-progress operations with “git —abort”. Works for merge, rebase, and a few other things, and can seriously save your bacon when you do a “git merge ” and are suddenly confronted with a bazillion merge conflicts. Also, if you’re in a panic because something went screwy, check “git status” and read every line carefully. status tells you a lot more than you might…
https://git-man-page-generator.lokaltog.net/#4b16e11f044dd60...
Re: How to undo almost anything with Git (2015)
#66Earlier quoted context omitted.
When I used to use NetBeans the main feature I loved was the history feature. Basically every save to every file was stored and diffable in a kind of self contained repo. I've missed this feature in every other editor since.
IntelliJ IDEA has that feature (local history)
Re: How to undo almost anything with Git (2015)
#67Earlier quoted context omitted.
If you have to use the command line, those "gosh darn it git" sites have some good recipes. Because if the problem is "I accidentally committed to the wrong branch!" who is going to remember all this off the top of their head: # undo the last commit, but leave the changes available git reset HEAD~ --soft git stash # move to the correct branch git checkout name-of-the-correct-branch git stash pop git add . # or add in…
I know you're trying to sell your SyntEvo(R) SmartGit(TM), but the last thing I'd want while already trying to recover from a mistake is having a third party tool do some opaque magic on the repo, in the same way that I wouldn't just copy-paste a recipe without understanding how it works. OTOH if a common operation can be performed reliably I'd much rather it be upstreamed.
Re: How to undo almost anything with Git (2015)
#68Earlier quoted context omitted.
If you have to use the command line, those "gosh darn it git" sites have some good recipes. Because if the problem is "I accidentally committed to the wrong branch!" who is going to remember all this off the top of their head: # undo the last commit, but leave the changes available git reset HEAD~ --soft git stash # move to the correct branch git checkout name-of-the-correct-branch git stash pop git add . # or add in…
> It works in conjunction with the command line Do you know of git GUIs that explicitly maintain a bijection between the GUI and the underlying command history? It'd be cool to use the GUI and see the command history, or use the CLI and see updates in the GUI.
Which GUI tool does not?
Re: How to undo almost anything with Git (2015)
#69Earlier quoted context omitted.
I'm not that poster, but Mercurial is just as powerful and much easier to use.
That's what everyone says, but for me, coming from a rebase heavy git workflow, I've found Mercurial far more difficult to learn. For example, with Mercurial, there's at least four different ways to do a rebase-ish thing: transplant, graft, rebase, and rebase (w/ evolve enabled). It's not obvious which a newbie should pick (rebase+evolve... I think?). Likewise, Mercurial has purge and strip which both delete commits…
You're cherrypicking--no pun intended.
By default, Mercurial doesn't do any of these operations; you have to activate extensions.
If I were a newbie coming from Git and I wanted a similar workflow using Mercurial, I would probably start with rebase.
But these days, the Evolve extension is the way to go--using it is a lot easier than anything I've seen or experienced using Git: https://www.mercurial-scm.org/doc/evolution/user-guide.html.
I find it kinda ironic when in this message thread, people are praising a chart like this--http://justinhileman.info/article/git-pretty/. It feels like the DVCS version of Helsinki Syndrome…
By design, Mercurial makes it much harder to shoot yourself in the foot.
In contrast, there's an entire cottage industry (https://ohshitgit.com and the like) to help when you--inevitably--get into a bad situation with Git.