News for hackers. Stuff that matters.
Re:Git Commands You Should Never Use by spicybright on Thursday November 26, 2020 @07:49AM (#25219553)
You don't have to be an expert in git to use these properly, especially re-base. If you find yourself arguing with Git most of the time, I recommend doing this:

1. Get a good night's sleep and wake up early, pour yourself a nice cup of coffee or your favorite beverage.

2. Open a copy of ProGit (free here: https://git-scm.com/book/en/v2) and read it cover to cover, while using something like Learn Git Branching (https://learngitbranching.js.org/) to try out what you're learning to get a better understanding.

3. Take a few walks and do your best to read the book cover to cover in a day.

4. Get a good night's sleep to cement the information in.

Git is not simple, but it's very powerful. But I also believe it doesn't take much to become an "expert" (if you already know how to edit text files and know basic command line usage + syntax). I don't think it's a lot to ask to block out a day or two to learn how it really works (at the very least chapter 10 in ProGit, Internals).

I see too many engineers arguing against git from a lack of understanding what commands actually do. Like it or not it's a corner stone of modern software development, and for some good reasons too.

Re:Git Commands You Should Never Use by wegs on Thursday November 26, 2020 @09:15AM (#25220176)
Nit: git is simple AND powerful.

Simple isn't the same as easy.

git is simple in the same way Lisp is simple, or Go is simple. git was hacked together in a couple weekends precisely because it's so incredibly simple. There are a few guides where you can write a git in a weekend (e.g. https://wyag.thb.lt/).

Really understanding git is really difficult, though.

A few years after you build a git, you'll get git. I've met only a handful of developers who really grok git, deeply, but it's a journey well worth taking.

The good news is that the surface understanding of git, from having built one, is enough to safely work with the complex commands that trip up most programmers. That's worth a weekend in itself.

Re:Git Commands You Should Never Use by kazinator on Thursday November 26, 2020 @01:25PM (#25222376)
Git was written by a notable "super-star" programmer, who also had a good understanding of and interest in existing advanced version control systems, and in managing integration flows in a large project with many third party contributions.
Re:Git Commands You Should Never Use by spicybright on Thursday November 26, 2020 @01:32PM (#25222443)
Very good nit pick, that exactly what I was trying to express, thank you.

I think I was trying to say git is dead simple under the hood, but has lots of useful layers built on top.

One thing beginners trip over a lot I find, is there's lots of ways to do things, and some of those ways overlap, which can be confusing if you don't know what's under the hood.

Re:Git Commands You Should Never Use by Topgamer7 on Thursday November 26, 2020 @07:43AM (#25219506)
Click bait title. Understand the requirements. Learn the commands capabilities and drawbacks. Implement as needed. Rebasing can be superbly useful, and submodules can too. Which I utilize both to great success. Don't give me this "never use" bull shit.
Re:Git Commands You Should Never Use by huy-nguyen on Thursday November 26, 2020 @07:17AM (#25219302)
Rebasing is very useful. For example, GitHub allows you to require that branches are “up to date” with (i.e. being direct children of) master before merging. This ensures that all changes team members makes in PRs are made against the latest version of master.
Re:Git Commands You Should Never Use by Rychard on Thursday November 26, 2020 @07:36AM (#25219456)
Rebase isn't the only solution for such scenarios. Merging remote/master into the source branch will serve the same purpose.
Re:Git Commands You Should Never Use by theamk on Thursday November 26, 2020 @08:36AM (#25219881)
This depends on read/write ratio of your code.

If your projects is mostly write-only, merging master into branch is the way to go. This keeps entry bar low, and team velocity high.

If you expect many people to read project’s history, it is worth learning how to rebase so that each individual commit has a clear purpose and can be understood standalone. A few minutes taken by rebase will save many much more time of your future source code readers.

Re:Git Commands You Should Never Use by whbrown on Thursday November 26, 2020 @12:27PM (#25221913)
Can you elaborate why you think merging master into the feat branch keeps team velocity higher than rebasing the feat branch with the latest version of master?

With rebasing, it seems to me to be easier to maintain a clean history (no merge commits) since all merges end up being fast forward, with the added benefit that I can deal with any conflicts as and when they come up rather than fixing them all at once when I eventually merge to master.

Re:Git Commands You Should Never Use by mytailorisrich on Thursday November 26, 2020 @02:51AM (#25217862)
Rebasing, and thus git rebase, is a standard step that predates git.

The typical workflow is that you create a branch off master and do your work on it. Once thw work is complete is rebase the branch if master has changed so that you can test and review independently, then perform a trivial merge.

Re:Git Commands You Should Never Use by pickledcods on Thursday November 26, 2020 @08:13AM (#25219741)
The epiphany I experienced with rebasing is that this is an incorrect visualisation of the workflow. It's not like you create a separate branch and work independent of master. It's more like working on a kind of local pre-release ahead of master.

You work on the development/pre-release, then consolidate by cherry-picking or otherwise, leaving all the todo's, spinoffs, experimental, personal notes in the pre-release. Like a reptile shedding its skin.

Re:Git Commands You Should Never Use by cmwelsh on Thursday November 26, 2020 @06:00PM (#25224167)
It was the default workflow when people used to share patch files as attachments on community forums. You could only diff your changes to the latest tip and send these changes to the maintainer as a “fast forward” merge. If the patch broke, you fixed it locally (rebase) and attached a new version for the maintainers to apply.
Re:Git Commands You Should Never Use by igornadj on Thursday November 26, 2020 @09:01AM (#25220064)
Rebase is only dangerous and problematic if your team shares ownership of feature branches. I have yet to work at a place where that is the case.

I have, however, seen many git trees that are a complete mess to grok because of merges into feature branches.

Re:Git Commands You Should Never Use by disgruntledphd2 on Thursday November 26, 2020 @09:06AM (#25220104)
Yeah, 23 commits into master from one feature branch is not normally a great idea.

When I worked at a large FAANG they enforced only one commit from a feature branch into master. I didn't realise why that was a good idea until I saw the alternatives ;)

Re:Git Commands You Should Never Use by matt-attack on Thursday November 26, 2020 @09:18AM (#25220201)
Can you explain “commits into master”? I thought you make a feature branch, do countless commits to it, then either merge or rebase into master. Where does the number of commits into master come Into play?
Re:Git Commands You Should Never Use by minot on Thursday November 26, 2020 @10:08AM (#25220611)
I’m guilty of doing things wrong.

Let’s say the cto has said no merge to master until after n days. I have a few defects that I need to work on that are in the same files. Ideally, one should make a different branch for each defect. However, I’ll have to deal with merge conflicts when I merge to master next week. So, I put multiple defects in the same branch and put tracking information in commit message for example

Use break word in result table

Since we allow first names to be up to a hundred characters in length, the table should stay within the constraints in its container even with a hundred no space characters For #4007

—

As you can imagine this isn’t ideal on multiple levels.

First, a merge request should only address one concern. That being said, the problem pretty much lies somewhere else.

The second follows the first. Assuming the first, we should be able to squash all commits in the feature branch without losing information.

I’m sure this is a common problem but I’ve not heard of a good solution to it so far. I’d love to hear what I should do differently.

Re:Git Commands You Should Never Use by disgruntledphd2 on Thursday November 26, 2020 @10:15AM (#25220678)
> Let’s say the cto has said no merge to master until after n days.

This seems like the problem you should address first.

Re:Git Commands You Should Never Use by minot on Thursday November 26, 2020 @11:33AM (#25221373)
Failed to meet deadline for release (not enough confidence that we can release without regressions) so release got pushed to next release window which is n - 1 days from now.

I imagine ideally we should use tags for release but for some reason we don't do that.

Re:Git Commands You Should Never Use by disgruntledphd2 on Thursday November 26, 2020 @10:14AM (#25220665)
So it's the notion that commits should be squashed before merging into master, rather than merging all N commits from the branch into master.
Re:Git Commands You Should Never Use by matt-attack on Thursday November 26, 2020 @09:20AM (#25220209)
How should more than one person collaborate on a new feature?
Re:Git Commands You Should Never Use by jamil7 on Thursday November 26, 2020 @10:08AM (#25220610)
Ideally the feature can be split into more granular components that individuals can work on.
Re:Git Commands You Should Never Use by Nginx487 on Thursday November 26, 2020 @08:44AM (#25219942)
"Git submodule". Did not even read further, author does not have an idea how to manage VCS
Re:Git Commands You Should Never Use by naetius on Thursday November 26, 2020 @11:25AM (#25221296)
Having to use my browser porn mode just to be able to read a simple post on Medium is a testament to how we should get rid of Medium before ranting about Git.
Re:Git Commands You Should Never Use by putsjoe on Thursday November 26, 2020 @10:01PM (#25225235)
Not sure what browser you use, but since disabling JavaScript for Medium (Chrome) it's been better.

I agree with you still though.

Re:Git Commands You Should Never Use by dusted on Thursday November 26, 2020 @08:41AM (#25219916)
Interestingly, I would switched two of those commands around.

NEVER EVER USE GIT MERGE! IT IS THE EVIL ONE! MERGE COMMITS ARE DEVILSPAWN AND MUCH BE CLEANSED WITH FIRE!!

Git rebase is great though, even if I usually prefer just to reset and cherry-pick.

My and my gits are headless most of the time anyway.