Live data from Hacker News

This is how I git

daniel.haxx.se

101–110 of 140 posts

Re: This is how I git

#101
I use git flow, and it took a while to get used to but I now do almost all of my git stuff in my IDE, pycharm.

I used to like tabbing over to terminal to run my git commands and do my diffs.

Now I use the git flow plugin and do my full process including amends, push, etc interactively.

Much of it can be done by keyboard and the closeness to the auto linting and reformatting has caught many small errors, left behind little items and generally improved code quality greatly.

Re: This is how I git

#102
> Never merge with GitHub!

While I agree with the spirit of this comment, in practice I do this:

1. Update:

    git pull --rebase
2. Clean up my commits:

    git rebase -i HEAD~X
3. Push:

    git push origin BRANCH -f
4. Merge in GitHub

Works pretty well for me. That being said, I would love to be able to take care of 2 and 3 within GitHub for branches that are already updated to the parent branch.

Re: This is how I git

#103
post #13

I use almost exactly this workflow with rclone. This bit resonated particularly: begin quote Never merge with GitHub! There’s a button GitHub that says “rebase and merge” that could theoretically be used for merging pull requests. I never use that (and if I could, I’d disable/hide it). The reasons are simply: I don’t feel that I have the proper control of the commit message(s) I can’t select to squash a subset of the…

We do squash-and-merge for PRs. Works great so far. A minimal unit of change is thus not a single commit in a PR, but the whole diff introduced with a PR.

Re: This is how I git

#104
post #66

Earlier quoted context omitted.

Does anyone know how to make this "cactus" workflow work better on github? We use it in our organization and between us we know to always manually rebase before merging. However, when we receive an external PR from someone else it's a pain. It's also easy to accidentally forget to rebase before merging.

You can allow rebase merging [1] while disabling other PR options, and require linear commit history [2] if desired. [1]: https://docs.github.com/en/free-pro-team@latest/github/admin... [2]: https://docs.github.com/en/free-pro-team@latest/github/admin...

Thanks, but I don't think that is quite what I want. What I mean by "cactus" history is that the feature branches have a linear history that starts at the tip of the master branch but when we merge them back into master we still use a merge commit. Looks like this:

      o-o-o   o-o-o   o-o
     /     \ /     \ /   \
    o-------o-------o-----o
We like doing that because, as the grandparent poster said, it clearly delineates the point where each PR was merged. AFAIK, the Gihub option to require a linear history assumes that you would want to flatten all the commits without any merge commits at all:

    o-o-o--o-o-o--o-o

Re: This is how I git

#105
post #66

Earlier quoted context omitted.

Does anyone know how to make this "cactus" workflow work better on github? We use it in our organization and between us we know to always manually rebase before merging. However, when we receive an external PR from someone else it's a pain. It's also easy to accidentally forget to rebase before merging.

I always go into each new repo I create and turn off the ability to merge and require commits to be up to date with master, I think this might get what you want?

Do you know can I enforce that a PR must be up to date with master before it can be merged? I don't remember seeing that option in the branch protection settings.

Re: This is how I git

#106

>Never stash Er, no. Right tool for the right job. Whilst I agree that the idea of putting differing lines of work into different branches is great, that's not what stash is for. That's what checkout is for. Stash is used to record the current state of the working directory and index while also returning to a clean working state. I guess for the author, stash is used to preserve changes when pulling in upstream chang…

git is versatile enough to enable the authors workflow and your workflow, where neither are invalid.

I’d be willing to bet they sometimes, even if rarely, use stash when as you say it’s the right tool to use.

I think the point is not stashing meaningful amounts of changes, as if they can be recalled later. Sounds like solid advice that requires some discipline

Re: This is how I git

#107

>Never stash Er, no. Right tool for the right job. Whilst I agree that the idea of putting differing lines of work into different branches is great, that's not what stash is for. That's what checkout is for. Stash is used to record the current state of the working directory and index while also returning to a clean working state. I guess for the author, stash is used to preserve changes when pulling in upstream chang…

git add . git commit -m "wip" when you're back git reset HEAD^ Keeps working changes nice and tidy in the branch they belong to, you can push them, and they are easily recoverable from the ref log, unlike stashes. Also, god help you when a stash fails to apply.

I do this all the time, it’s the only real way of saving state when you are abruptly asked to do something else

Re: This is how I git

#108
post #49

Earlier quoted context omitted.

I use them to stash changes to config files that remain fairly stable across branches but require local paths, etc. I realize this isn't a best practice for config files but it is what I need to do for my particular mountain of technical debt. This works particularly well since the config files rarely change in a permanent way. I will only do it short term, though. For me, Stash is a tool I use sparingly as a conveni…

> I use them to stash changes to config files that remain fairly stable across branches but require local paths, etc. I had to resort to git's assume-unchanged[O] to keep these changes out of commits made in the heat of battle. > this isn't a best practice for config files Have had great results (in dotnet land) with MS' Secrets Manager[1]. [0] https://www.git-scm.com/docs/git-update-index [1] https://docs.microsoft.…

Thanks, I will review that. We are working on ASP.NET stuff and using Web.configs in a non-standard way (don't get me started) to store encrypted strings for... anyway, you get the idea. This is in the queue to get overhauled soon, so hopefully won't be an issue much longer (if you squint, you can see the end of the todo list wayyy back there). Maybe I should check this out.

Re: This is how I git

#109

>Never stash Er, no. Right tool for the right job. Whilst I agree that the idea of putting differing lines of work into different branches is great, that's not what stash is for. That's what checkout is for. Stash is used to record the current state of the working directory and index while also returning to a clean working state. I guess for the author, stash is used to preserve changes when pulling in upstream chang…

Adopting a policy to never stash is a good idea, because "If you mistakenly drop or clear stash entries, they cannot be recovered through the normal safety mechanisms." https://git-scm.com/docs/git-stash

Re: This is how I git

#110

only related by "git" but while I believe i'm fairly proficient in git I'm not sure how to go about explaining to an inexperienced person how to fix a merge conflict. It feels like not a simple thing to explain. As an example someone sent me a PR with 15 commits. github claims only 1 file has changed and it's a new file so no conflicts (which AFAIK is correct) but git complains that somewhere around commit 4 there's…

> git complains that somewhere around commit 4 there's a conflict.

That sounds like a rebase merge, which might be the setting in the repo. A normal merge wouldn't attempt commit by commit.

Post reply on HN