Live data from Hacker News

Git rebase -i is not that scary

cachebag.sh

71–80 of 155 posts

Re: Git rebase -i is not that scary

#71
post #59

Earlier quoted context omitted.

> as long as I keep their hashes that means my hashes or their hashes or them keeping my hashes, I am never sure

you can just make a backup copy of .git or your entire project dir. When you get lost, just delete your .git, copy from the backup and try again

You never need to do that. git-reflog(1) is the most general solution if you will ever need.

Re: Git rebase -i is not that scary

#72

One additional thing I would mention ist that: When resolving conflicts never try to solve them for the final result. Consider each conflict without considering how the code will change in a later commit. I’ve seen people die a painful rebase death because of this.

Yeah like the other commenter below mentioned, `rerere` takes a lot of the pain out of layering rebased changes. It's important (IMO) to make sure each commit still contains a logical change and a working system, even with an incremental rebase.

Re: Git rebase -i is not that scary

#73
post #69
post #68

Earlier quoted context omitted.

When I interview someone and they are scared of `git rebase -i` it's a huge red flag. Git rebase has such foundational data structures and concepts that you couldn't pass a serious college programming course without grokking it. The only reason someone would be scared of git rebase is: a) they don't know the basics of programming/software engineering b) they are not intellectually curious enough to look into how tf t…

I'm genuinely unsure why rebase interactive is more scary than rebase

Yeah I never use non-interactive rebase. Even if I don't need to edit the todo list, reading it gives me a confirmation of what git will do.

Re: Git rebase -i is not that scary

#74
post #68

I feel like if you're scared of rebasing, you don't actually understand git.

When I interview someone and they are scared of `git rebase -i` it's a huge red flag. Git rebase has such foundational data structures and concepts that you couldn't pass a serious college programming course without grokking it. The only reason someone would be scared of git rebase is: a) they don't know the basics of programming/software engineering b) they are not intellectually curious enough to look into how tf t…

I wonder if it's because it opens in the default visual editor (typically vi/vim) and while I'm primarily a (neo)vim user now, it is certainly not the most intuitive editor to get started with without guidance.

Re: Git rebase -i is not that scary

#75

One additional thing I would mention ist that: When resolving conflicts never try to solve them for the final result. Consider each conflict without considering how the code will change in a later commit. I’ve seen people die a painful rebase death because of this.

rerere

this is not a cat on a keyboard. it is the name of a git command that does this.

Re: Git rebase -i is not that scary

#76
post #59

Earlier quoted context omitted.

> as long as I keep their hashes that means my hashes or their hashes or them keeping my hashes, I am never sure

you can just make a backup copy of .git or your entire project dir. When you get lost, just delete your .git, copy from the backup and try again

Is this a joke? git's whole purpose is to save the history of your project and return to earlier versions when needed

Re: Git rebase -i is not that scary

#77
> it is very hard to actually lose work here, for three reasons.

The opposite is true, of course, for example: you move commits arround, start to resolve conflicts, and after a few steps you realize you can't, so when you

> you can bail out at any time. as aforementioned with git rebase --abort

Yep, except for all the work you've done resolving the conflict, that's "aborted"

> the old commits still exist in git’s object database, unreferenced but intact,

The best UI there is - some hidded data store you're, of course, intimately familiar with, so won't have any trouble getting data out of. Oh, wait, you didn't even know it existed? Tough luck, git gud to avoid data loss!

> botched rebase is a few minutes of you perusing through the reflog.

Unless, of course, your not that sharp to remember all the commits from their names and would also like to see the diff contents to connect to your code work. But that's just more minutes extra, not that big of a loss.

> there’s of course, the low-tech insurance policy: git branch backup-before-rebase

Finally some sensible advice, one that should be the default backup plan to save userst he trouble of wasting "few minutes" perusing the logs

Re: Git rebase -i is not that scary

#78
post #68

Earlier quoted context omitted.

When I interview someone and they are scared of `git rebase -i` it's a huge red flag. Git rebase has such foundational data structures and concepts that you couldn't pass a serious college programming course without grokking it. The only reason someone would be scared of git rebase is: a) they don't know the basics of programming/software engineering b) they are not intellectually curious enough to look into how tf t…

An interviewer asking me about git rebase is the huge red flag

Genuine question, why? It seems like a reasonable knowledge check that can be answered in a few sentences.

Re: Git rebase -i is not that scary

#79

Earlier quoted context omitted.

I still don't know it very well, and it's been well over a decade. I think it's a combination of a few things: - I find it uninteresting. My version control needs are very simple. - Most teams I have been in use a small subset of it. - It's confusing terms and inconsistent cli are huge warning signs to not go down that rabbithole. Today instead of learning Git I read some Tony Hoare, much better. I've been at once pl…

Give it an hour or two. It is really not that complicated. A little bit of investment will pay huge dividends. Do yourself the favor.

I could say the same for reading Tony Hoare.

Re: Git rebase -i is not that scary

#80
A workflow I was introduced to and have worked with a lot in my teams is,

1. Everyone uses feature branches

2. Everyone cleans up their branch using interactive rebase on top of main before review

3. All merges have been freshly rebase on main

I think it works very well and keeps the history clean while preserving "each commit does one thing".

Post reply on HN