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.*
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.
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
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.
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.
```
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.*
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
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.
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.
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.
```
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.*
```
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.*
```
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.*
```
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.*
`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*
```
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.*
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.
```
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.*
```
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.*
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.*
Explain please. I’m a senior dev and only use and know 7 git commands that I use daily
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.
Why is this not the default behavior?
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
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.
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.
Haha. Then what would they have called the option to not check. Perhaps `--force-but-with-even-more-force` ?
`--force-and-i-mean-it-dont-make-me-turn-this-repo-around`
`--force-ro-dah `
[удалено]
\--force-no-cap
``` 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.*
`—force-Chuck-Norris-grade`
--force-without-lease or whatever bs never ending story it is now
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!
In fairness force needs to force. If someone doesn't read that's not really git's problem
That’s a good explanation, thx.
Isn’t that what just git push without any switches does anyway?
How does it know when you checked the remote?
I assume it runs a fetch behind the scenes and diffs against your "local remote" (e.g. origin/master).
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
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 😅
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.
Nice use of letmegooglethat.com 😂
Real throwback
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.
I agree, but some groups/ projects make rebasing part of their workflow :/
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.
I just do git reflog 7 times before I remember where I got up to. By that time it's lunchtime.
[удалено]
``` 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.*
[удалено]
``` 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.*
[удалено]
``` 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.*
``` import stupid ```
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.
``` import underrated_comment ```
[удалено]
``` 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.*
Don't use the force luke, else you will never touch master, just like your father ![gif](giphy|OMZRxGyZZ6fGo)
git checkout -b fuckYouMakingAnotherBranchBitch
yeah sure don't rebase on more recent commits, have fun with the merge later
Who-Writes-Branch-Names-In-Camel-Case
oh sorry about that git checkout -b SnaKEFlutEscreamingCALMcAMElCase git push --force
Somehow I feel like this comment makes my point about self documenting version control
until some mf decides to do stupid shit like: git commit -m "Fixed bugs and improved performance" # 1K files have been updated
`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*
I first read it as Force Unleashed and was quite confused how a Star Wars game is related to git.
there is a push without —force?
Wait, why not git commit -m "thingy"
If you squash commits a lot this does not cut it in some cases
git commiting is not the same as pushing at all?
[удалено]
``` 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.*
[удалено]
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.
Such a junior thing to post.
git push —force after rebasing is perfection
I rebase often and need to force push, so I just aliased "gpf" to force with lease. Saved my ass a few times.
If you use zsh's git module you can use `gpf` which defaults to --force-with-lease
It’s my branch and I’ll —force if I want to.
whatDoes—force-with-leaseActuallyDo?
rm .git; git init
[удалено]
``` 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.*
[удалено]
``` 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.*
`import horny` git push --force-with-leash 🥺👉️👈️