r/ProgrammerHumor • • 2d ago

Meme [ Removed by moderator ]

/r/ProgrammerHumor/comments/1y5zctl/removed_by_moderator/

[removed] — view removed post

5.2k Upvotes

353 comments sorted by

View all comments

Show parent comment

10

u/Steinrikur 1d ago

My gitconfig is full of aliases for this kind of stuff, pusho for pushing a new branch to origin, deletebranch to delete it locally and remote, etc.

AI can write a commit message, but I'll be the one to push it.

5

u/Jemnite 1d ago

I just set up rules. Also I don't let the AI write a commit message either because if I haven't sufficiently understood the changes enough to write the commit message I probably shouldn't commit it.

2

u/Steinrikur 1d ago

Good point about understanding the commit message. I do rebase and rewrite a lot, but AI is actually better than I am at writing a concise message.

3

u/dcheesi 1d ago

I'm as terse as possible, in the finest Unix fashion (fewer letters, fewer typos :)

gd, gdc, gdm, gdmc, gmm, gch, gcp, etc.

10

u/korneev123123 1d ago

git has it's own alias system. For example, I set alias co = checkout, and the best part is that bash completion understands this automatically, and suggests valid targets for checkout. Bash-level aliases won't do that.

3

u/JontesReddit 1d ago

git's new alias system supports any unicode character now by the way.

New "subsection" aliases will in future releases have more properties than command.

Subsection alises do not replace traditional aliases.

# Traditional alias
[alias]
  co = checkout
# New alias
[alias "co"]
  command = checkout

1

u/Tohaker 1d ago

You can set new branches to push to origin automatically with the push.autoSetupRemote config flag. Been part of my default setup for years.

1

u/Steinrikur 1d ago

I know. If you don't have that set, the error message will tell you:

> To have this happen automatically for branches without a tracking
> upstream, see 'push.autoSetupRemote' in 'git help config'.

But the point is that I don't want to do it automatically, and arrow-up + 'o' will create it plenty fast enough for me. And I will never accidentally create an upstream branch.

1

u/the-liquidian 1d ago

I like pusho. I have been doing git push -u original HEAD like a chump

1

u/Steinrikur 1d ago

I do a bit more than that.
pusho = '!f() { local b=$(git symbolic-ref --short HEAD); git push --set-upstream origin ${b?Not on a branch}; }; f '

If it complains 'fatal: The current branch private/me/whatever has no upstream branch. ...' I know I am on a new branch and need to do git pusho to fix it.
If it complains '! [rejected] private/me/whatever-> private/me/whatever (non-fast-forward) ...' I know I am rewriting history and need to do git push -f to fix it.

And I don't push some shit by accident.

1

u/the-liquidian 1d ago

Your git-fu is way more sophisticated than mine.

1

u/Steinrikur 1d ago edited 19h ago

It actually works better as

pusho = '!f() { b=$(git symbolic-ref --short HEAD) && git push --set-upstream origin $b; }; f ' 

While I'm at it. Some other personal favorites:

# prettier log output
[pretty]
  lg = %C(auto)%h -%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset
 [alias]
# prettier log output - needs the pretty.lg above
      lg = log --graph --pretty=lg --date=short
      lga = log --graph --pretty=lg --date=short --all
      lgs = log --graph --pretty=lg --date=short --stat
 #Roll through all repos in a folder, doing the same command, like git lg -2
    recursive = "!f() { find . -maxdepth 3  -name .git -printf '%h\n' | while read i ; do (cd $i && realpath . && git \"$@\"); done }; f "
  # collection of "fix merge issues" commands
     conflict = diff --name-only --diff-filter=U
     conflictfix = "!f() { for i in \"$@\"; do meld $i;done }; f $(git diff --name-only --diff-filter=U)"
     conflictadd = !git add -v $(git diff --name-only --diff-filter=U)
# show diff to upstream
    do = "!f() { b=$(git symbolic-ref --short HEAD) && git diff origin/$b $@; }; f"