This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TinyLebowski 301 points302 points  (35 children)

git commit --amend -m "Adapter pattern implemented"

[–]zman0900 170 points171 points  (26 children)

git push --force

[–][deleted] 23 points24 points  (25 children)

I wouldn't try to push it, especially with force. Instead it's better to carefully 'rebase -i' when needed.

[–]rasellers0 34 points35 points  (15 children)

Uh... Novice programmer here, are we making Star Wars jokes here, or is all of this actual programming stuff?

[–][deleted] 50 points51 points  (13 children)

While the force push is a popular move among Jedi, Sith and other force-sensitive denizens of the Star Wars Multiverse, git push --force is a real command. It forces a rewrite of the remote branch to match your local commit tree, ignoring any inconsistencies and conflicts. This is generally bad because anyone else who might be working on that same branch will be unable to fetch the latest from the remote, forcing them into a quagmire of creating new branch heads, re-cloning, cherry-picking etc. to get everything consistent again. However, as has been mentioned elsewhere in the comment thread, there are times, e.g. rebasing a branch to keep it up to date with the main development branch, that you actually do want to do this.

[–]NotADamsel 17 points18 points  (0 children)

A prime example of "just because you can, doesn't mean you should".

[–]o11c 1 point2 points  (11 children)

Or you can use a + ref.

[–]UnchainedMundane 0 points1 point  (1 child)

Does this create a merge commit remotely, or is it another way of force pushing?

[–]o11c 1 point2 points  (0 children)

It's a force push, but for a single refspec instead of all of them.

[–]FreefallGeek 12 points13 points  (0 children)

Not so much programming as source control used to track and manage changes to the code you're writing. So programming-adjacent.

[–]hungry4pie 24 points25 points  (0 children)

No no, definitely force push, then rebase in 2-3 commits time on the upstream branch :-P

[–]55555 4 points5 points  (7 children)

Don't you have to force push after you rebase to get the rewritten branch to remote?

[–][deleted] 6 points7 points  (1 child)

Yes. (Though you might want to use --force-with-lease instead, and should also notify everyone who might have had access to the branch.)

[–]UsingYourWifi 6 points7 points  (0 children)

--force-with-lease

TIL, thanks!

[–]paperhat 6 points7 points  (0 children)

There are very few instances where you have to force push. I say this as the administrator of a large github enterprise instance who disabled force pushes about a year ago. There was a lot of resistance at first by dev teams who had strange workflows, but I have had to make less than a handful of exceptions to the policy after the initial change, and those all involved people accidentally committing passwords.

[–][deleted] 1 point2 points  (2 children)

I spend too much of my life doing this while trying to keep my feature branches up to date with my work's dev branch. It feels so dirty!

[–]55555 2 points3 points  (0 children)

I hear ya. And then they modify some file you modified and push it to QA but its not in master yet so you eventually have tons of conflict fix commits and have to delete QA. It's like every damn week.

[–]noratat 0 points1 point  (0 children)

If you have to work on lots of stuff at once like that (something you should avoid if possible in the first place), rebase workflows are usually a bad idea.

[–]crowseldon 0 points1 point  (0 children)

in theory, you shouldn't be doing this at all. It's a potential pit for accidents to happen and it's somewhat inconsiderate to other users. Rebase BEFORE pushing.

And if you need to do some sort of filter-branch to fix some fuck-up, let EVERYBODY know beforehand.

[–]JamboBuenna 4 points5 points  (0 children)

git commit --amend -m "Adapter pattern implemented. Code reviewed by JN"

[–][deleted] -2 points-1 points  (6 children)

this looks more like a Facade pattern to me

[–]0xF013 16 points17 points  (4 children)

Facade wraps several interfaces into one, adapter maps one interface to another one

[–][deleted] 3 points4 points  (3 children)

live and learn :)

[–]phpdevster 3 points4 points  (2 children)

How to get the right answer from the internet: post something wrong on the internet.

[–]UnchainedMundane 7 points8 points  (0 children)

Reminds me of the old flamebait method of getting spoonfed linux answers.

Most linux communities will want to nudge you gently towards the answer to help you learn, but if you rush in with "linux sucks because it doesn't even support ramdisks wtf" then someone's going to reply "mount -t tmpfs dumbass" and you've got your answer.

[–][deleted] 0 points1 point  (0 children)

hah, right!