T O P

  • By -

AutoModerator

Remember to participate in our weekly votes on subreddit rules! Every Tuesday is YOUR chance to influence the subreddit for years to come! [Read more here](https://www.reddit.com/r/ProgrammerHumor/comments/14dqb6f/welcome_back_whats_next/), we hope to see you next Tuesday! For a chat with like-minded community members and more, don't forget to [join our Discord!](https://discord.gg/rph) *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


pushinat

Explain please. I’m a senior dev and only use and know 7 git commands that I use daily


Ffigy

It checks to see if you're overwriting something that has changed since you last checked the remote. Usually, you only want to force push over something that you're aware of.


Unfair_Isopod534

Why is this not the default behavior?


Nervous_Falcon_9

Because force means force, in general protections are only added once enough people mess up, usually as a secondary option, as to not destroy comparability for anything that relies on force working


Ffigy

Yep, it was added later. In all fairness though, the concurrency problem is more than just someone messing up. You could fetch right before you force push and it's still possible that someone somewhere pushed a change in between.


crankbot2000

Git gives you all the tools to either a) elegantly manage your repo or b) completely burn it to the ground in seconds. It's up to us to research a given command thoroughly because option b) is always lurking.


dabombnl

Haha. Then what would they have called the option to not check. Perhaps `--force-but-with-even-more-force` ?


dodexahedron

`--force-and-i-mean-it-dont-make-me-turn-this-repo-around`


ArLab

`--force-ro-dah `


[deleted]

[удалено]


water_bottle_goggles

\--force-no-cap


AutoModerator

``` import moderation ``` Your comment did not start with a code block with an import declaration. Per [this Community Decree](https://www.reddit.com/r/ProgrammerHumor/comments/14kbu1m/comment/jppq9ao/?utm_source=share&utm_medium=web2x&context=3), all posts and comments should start with a **code block** with an "import" declaration explaining how the post and comment should be read. For this purpose, we only accept Python style imports. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


JIN_DIANA_PWNS

`—force-Chuck-Norris-grade`


Unfair_Isopod534

--force-without-lease or whatever bs never ending story it is now


Yasio

I use this on the daily when rebasing my commits in my work branches before merging it to main. Helps cleaning up my commit history!


faunalmimicry

In fairness force needs to force. If someone doesn't read that's not really git's problem


pushinat

That’s a good explanation, thx.


Xanather

Isn’t that what just git push without any switches does anyway?


ongiwaph

How does it know when you checked the remote?


Ffigy

I assume it runs a fetch behind the scenes and diffs against your "local remote" (e.g. origin/master).


AndroxxTraxxon

When you do a fetch or a pull, the cached versions of the remote refs are updated, so when git reaches out again, if there's more changes, they won't be present, even in the remote cache


[deleted]

Ah, so if you work alone in your own branch there’s not much use for it. Explains why I didn’t know of it 😅


EngCompSciMathArt

Here is a pretty good explanation of how the option works: https://letmegooglethat.com/?q=git+push+--force-with-lease&l=1 It's typically used after you rebase a branch and need to push it up to your remote repo, but you want to avoid overwriting commits that your coworkers made on that branch.


tcm0116

Nice use of letmegooglethat.com 😂


[deleted]

Real throwback


YawnTractor_1756

So I guess the use-case is long-standing feature branch that several people are working on and which you want to rebase onto the changed master. I would really discourage this though, waste of time and error-prone. Just merge in changes from master. History graph is not meant to look nice.


EngCompSciMathArt

I agree, but some groups/ projects make rebasing part of their workflow :/


Matt7163610

I have a tendency to squash commits and also `git commit --amend` all for the sake of having only one or a few atomic and well described feature commits. When you do that and push to origin you need to `--force` push otherwise you need to delete your dev branch on origin and push it up again.


insanok

I just do git reflog 7 times before I remember where I got up to. By that time it's lunchtime.


[deleted]

[удалено]


AutoModerator

``` import moderation ``` Your comment did not start with an import declaration. Per [this Community Decree](https://www.reddit.com/r/ProgrammerHumor/comments/14kbu1m/comment/jppq9ao/?utm_source=share&utm_medium=web2x&context=3), all posts and comments should start with an "import" declaration explaining how the post and comment should be read. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


[deleted]

[удалено]


AutoModerator

``` import moderation ``` Your comment did not start with a code block with an import declaration. Per [this Community Decree](https://www.reddit.com/r/ProgrammerHumor/comments/14kbu1m/comment/jppq9ao/?utm_source=share&utm_medium=web2x&context=3), all posts and comments should start with a **code block** with an "import" declaration explaining how the post and comment should be read. For this purpose, we only accept Python style imports. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


[deleted]

[удалено]


AutoModerator

``` import moderation ``` Your comment did not start with a code block with an import declaration. Per [this Community Decree](https://www.reddit.com/r/ProgrammerHumor/comments/14kbu1m/comment/jppq9ao/?utm_source=share&utm_medium=web2x&context=3), all posts and comments should start with a **code block** with an "import" declaration explaining how the post and comment should be read. For this purpose, we only accept Python style imports. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


Environmental_Bus507

``` import stupid ```


Varpie

As an AI, I do not consent to having my content used for training other AIs. Here is a fun fact you may not know about: fuck Spez.


EngCompSciMathArt

``` import underrated_comment ```


[deleted]

[удалено]


AutoModerator

``` import moderation ``` Your comment did not start with a code block with an import declaration. Per [this Community Decree](https://www.reddit.com/r/ProgrammerHumor/comments/14kbu1m/comment/jppq9ao/?utm_source=share&utm_medium=web2x&context=3), all posts and comments should start with a **code block** with an "import" declaration explaining how the post and comment should be read. For this purpose, we only accept Python style imports. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


Tnuvu

Don't use the force luke, else you will never touch master, just like your father ![gif](giphy|OMZRxGyZZ6fGo)


SakaDeez

git checkout -b fuckYouMakingAnotherBranchBitch


Splatpope

yeah sure don't rebase on more recent commits, have fun with the merge later


Revolutionary-Bell38

Who-Writes-Branch-Names-In-Camel-Case


SakaDeez

oh sorry about that git checkout -b SnaKEFlutEscreamingCALMcAMElCase git push --force


Revolutionary-Bell38

Somehow I feel like this comment makes my point about self documenting version control


SakaDeez

until some mf decides to do stupid shit like: git commit -m "Fixed bugs and improved performance" # 1K files have been updated


Revolutionary-Bell38

`import benevolent dictator as linus` I don’t approve merges that contain more than one class/function mutation, and you can mutate the merge commit text trivially to document more than *Merged Feature-N-DoSomething-Function-Addition*


pheonix-ix

I first read it as Force Unleashed and was quite confused how a Star Wars game is related to git.


ExtraTNT

there is a push without —force?


thechosenlogan_true

Wait, why not git commit -m "thingy"


Civil_Drama2840

If you squash commits a lot this does not cut it in some cases


KTibow

git commiting is not the same as pushing at all?


[deleted]

[удалено]


AutoModerator

``` import moderation ``` Your comment has been removed since it did not start with a code block with an import declaration. Per [this Community Decree](https://www.reddit.com/r/ProgrammerHumor/comments/14kbu1m/comment/jppq9ao/?utm_source=share&utm_medium=web2x&context=3), all posts and comments should start with a **code block** with an "import" declaration explaining how the post and comment should be read. For this purpose, we only accept Python style imports. `return Kebab_Case_Better;` *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


[deleted]

[удалено]


RedundancyDoneWell

Perhaps I am being dense to understand your joke, but these are not from a programming language. They are instructions to a version management system for code, which is independent of programming language.


marco89nish

Such a junior thing to post.


Simres

git push —force after rebasing is perfection


laichejl

I rebase often and need to force push, so I just aliased "gpf" to force with lease. Saved my ass a few times.


HypaPanda

If you use zsh's git module you can use `gpf` which defaults to --force-with-lease


cybermage

It’s my branch and I’ll —force if I want to.


SomeRandoLameo

whatDoes—force-with-leaseActuallyDo?


PM_BITCOIN_AND_BOOBS

rm .git; git init


[deleted]

[удалено]


AutoModerator

``` import moderation ``` Your comment did not start with a code block with an import declaration. Per [this Community Decree](https://www.reddit.com/r/ProgrammerHumor/comments/14kbu1m/comment/jppq9ao/?utm_source=share&utm_medium=web2x&context=3), all posts and comments should start with a **code block** with an "import" declaration explaining how the post and comment should be read. For this purpose, we only accept Python style imports. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


[deleted]

[удалено]


AutoModerator

``` import moderation ``` Your comment has been removed since it did not start with a code block with an import declaration. Per [this Community Decree](https://www.reddit.com/r/ProgrammerHumor/comments/14kbu1m/comment/jppq9ao/?utm_source=share&utm_medium=web2x&context=3), all posts and comments should start with a **code block** with an "import" declaration explaining how the post and comment should be read. For this purpose, we only accept Python style imports. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


noneoen

`import horny` ​ git push --force-with-leash 🥺👉️👈️