As aliases

alias g-log="git log --graph --format='format:%C(yellow)%h%C(reset) %s %C(magenta)%cr%C(reset)%C(auto)%d%C(reset)'"
alias g-history='gitk --all &'
alias g-checkout='git checkout $(git branch --sort=-committerdate --no-merged | fzf)'
alias g-commit='git citool &'
alias g-amend='git citool --amend &'
alias g-rebase='git rebase --interactive --autosquash'
alias g-pull='git pull --verbose --rebase'
alias g-pushf='git push --verbose --force-with-lease'
alias g-status='git status --ignored'
alias g-clean='git clean -fdx && git reset --hard && git submodule foreach --recursive git clean -fdx && git submodule foreach --recursive git reset --hard'
You are viewing a single thread.
View all comments
17 points

If you need anything more complex than cherrypick, you already screwed up big time.

permalink
report
reply
10 points
*

If you need anything more complex than cherrypick, you already screwed up big time.

I think this is a clueless comment. You can use Git to greatly improve your development workflow if you dare going beyond the naive pull/commit/push workflow.

Take for example interactive rebase. It let’s you do very powerful stuff such as changing the order of commits in a local branch and merge/squash contiguous commits. This unlocks workflows such as peeling off bugfix and cleanup commits from your local feature branch without having to switch branches. I’m talking about doing something like:

a) - you’re working on your task, b) - you notice a bug that needs fixing, c) - you fix the bug and commit your fix, e) - you continue to work on your task, f) - you notice a typo in your bugfix code, so you post a fixup commit. g) - you post a few commits to finish your task, h) - you noticed your bugfix commit didn’t had the right formatting, so you post a couple of commits to lint your code both in your bugfix commits and task.

When you feel you’re done, you use interactive rebase to put everything together.

a) you reorder your commits to move your bugfix commit to the top of your local branch, followed by the typo fixup commit and the linter commit. b) you mark both the typo and linter commits as fixup commits to merge them with the bugfix one, c) you post a PR with the single bugfix commit, d) you finally post a PR for your task.

Notice that thanks go git interactive rebase you did not had to break out of your workflow or do any sort of context switch to push multiple PRs. You just worked on things you had to work, and in the end you just reorganize the commit history in your local branch to push your work.

Is this what you call “screwed up big time”?

permalink
report
parent
reply
7 points

That sounds like a solution in desperate need for a problem.

All the “problems” you described boil down to “switching branches is evil”.

permalink
report
parent
reply
1 point
*
Deleted by creator
permalink
report
parent
reply
-12 points

That sounds like a solution in desperate need for a problem.

It’s ok if you never did any professional software development work. Those who do have to go through these workflows on a daily basis. Some people don’t even understand why version control systems are used or useful, and that is perfectly ok. Those who do work have to understand how to use their tools, and those who don’t can go about their life without even bothering with this stuff.

permalink
report
parent
reply
1 point

It doesn’t disrupt my workflow to switch branches and it’s much faster than some ugly rebase

permalink
report
parent
reply
1 point

It’s ok if you don’t feel a need to change your persona workflow.

Nevertheless I’m not sure you understood the example, so I’m not sure you fully grasp the differences.

The whole point of my example was to point out the fact that, thanks to interactive rebase, you do not even need to switch branches to work on multiple unrelated PRs. You can just keep going by doing small commits to your local feature branch and keep doing what you’re doing. In the end all you need to do is simply reorder, squash, and even drop commits to put together multiple PRs from commits that are built upon each other.

Simple, and straight to the point.

permalink
report
parent
reply
0 points

Yes, why are you wasting time with all that. No one uses the commit history to the level that any of that matters. If it does, you ci flow is the problem.

permalink
report
parent
reply
7 points

I disagree wholeheartedly with this. I consider the commit history as documentation for pull requests and for future history, and as such I make liberal use of interactive rebasing to curate my commits.

Rebasing in general is one of those things that I picked up fairly late, but now it’s essential to my git workflow.

permalink
report
parent
reply
3 points

What’s ironic is that rebases aren’t as hard as many consider it to be. Once you’ve done it a couple of times, you just do it everyday as easily as you commit changes.

permalink
report
parent
reply
1 point

Absolutely. I think it helps a lot to understand the mechanics of git and rebasing, but after a few times it just makes more sense than merging, really.

permalink
report
parent
reply
2 points

I’ve been using git for some three years now - never used Cherrypick (not consciously, anyway).

permalink
report
parent
reply
1 point
*

If you’re doing more complex stuff all the time then yes that’s an indication of a problem, but despite your best efforts, complex situations or screw ups do happen and it’s good to know how to fix them, especially if you’re a senior dev that needs to help the rest of the team and resolve conflicts between feature branches. The whole team can’t be perfect all the time.

Also most of the tips in the article aren’t even about branch management and more about optimizations for huge projects or introspection into the history of large projects.

permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 3.2K

    Monthly active users

  • 1.8K

    Posts

  • 30K

    Comments