what exactly happens when you git click on --force?
I searched on the Internet for about an hour, and the most important answer I can find is:
Same as [git push], but force the push even if it results in a non-fast-forward merge. Do not use the --force flag unless you're absolutely sure you know what you're doing.
-source from https://www.atlassian.com/git/tutorial/remote-repositories#!push
I understand this quite well, I think, but for me it seems like git push --force will push. Despite my searches, I cannot find anything specific that describes the process associated with force pushing.
Hypothetically, I have a basic repo setup called git @ heroku.com: my-app.git, and a mirror of this repo configured on Heroku for a production called git @ heroku.com: my- application-staging.git.
I created a local branch named "new_changes", did the job, and clicked on a stage from this branch.
I did not like the results, so I abandoned the project, created a new branch named "more_new_changes", did some work, tested it locally, teamed up with the master and tried to click on the stage, just to make sure the setting is relevant.
My press tells me ...
Pushing to git@heroku.com :my-app-staging.git Fetching repository, done. To git@heroku.com :my-app-staging.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to ' git@heroku.com :my-app-staging.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (eg 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.
I do not want to combine the code that is in my local branch of the wizard - in fact, I want this intermediate code to disappear. (Obviously, branches would be called hashes, but for an argument), I suppose if my setting looks like
push079 β push080 β new_changes(HEAD)
and my local looks like
push079 β push080 β more_new_changes(HEAD)
and I decided to click on the stage using -force, then the result will be an intermediate branch that looks like
push079 β push080 β more_new_changes(HEAD)
Alternatively, it may look more like
push079 β push080 β new_changes
\
> more_new_changes(HEAD)
but if I am wrong and he just crush them together and I finish something like
push079 β push080 β new_changes β more_new_changes(HEAD)
then I lose the continuity of having an intermediate repo that reflects the mirror of my production repo.
So, what really happens behind the scenes when you click the --force button?