8/8/2023 0 Comments Git push command![]() ![]() Note the double quote, which get_oid has reminded us is not valid in an hex object ID.Įven if we had been able to parse it, we would send the wrong data to the server: we'd send an escaped ref, which would not behave as the user wanted and might accidentally result in updating or deleting a ref we hadn't intended. However, the remote curl helper isn't designed to parse such an argument, meaning that if we try to use -force-with-lease with an HTTP push and a non-ASCII refname, we get an error like this: error: cannot parse expected object name '0000000000000000000000000000000000000000"' This is the case for the cas option, which implements the -force-with-lease command-line flag, when we're passing a non-ASCII refname. When we invoke a remote transport helper and pass an option with an argument, we quote the argument as a C-style string if necessary. (Merged by Junio C Hamano - gitster - in commit c2796ac, ) remote-curl: make -force-with-lease work with non-ASCII ref names It is not ignored per se, it is just now you have identical refs for local remote head and remote head, so -force-with-lease will behave correctly - compare these two, and if in that interval of time between fetch and push, someone updated remote, it won't behave as -force, it will still fail.Īnother difference: before Git 2.29 (Q4 2020), pushing a ref whose name contains non-ASCII character with the " -force-with-lease" option did not work over smart HTTP protocol. force"Īs I mentioned in " push -force-with-lease by default", as Git 2.13 (Q2 2017) mentions, that the option -force-with-lease can be ignored if a background process (like the ones you find in an IDE with a Git plugin) runs git fetch origin. You assume you took the lease on the ref when you fetched to decide what the rebased history should be, and you can push back only if the This round calls it "force-with-lease".The second attempt called it "lockref" (because it is conceptually like pushing after taking a lock) but the word "lock" was hated because it implied that it may reject push by others, which is not the way this option works.This option was originally called " cas" (for "compare and swap"), the name which nobody liked because it was too technical." force-with-lease": You assume you took the lease on the ref when you fetched to decide what the rebased history should be, and you can push back only if the lease has not been broken. force-with-lease will protect all remote refs that are going to be updated by requiring their current value to be the same as some reasonable default, unless otherwise specified įor now, "some reasonable default" is tentatively defined as " the value of the remote-tracking branch we have for the ref of the remote being updated", and it is an error if we do not have such a remote-tracking branch. That feature was introduced in this commit (Dec. The latter only pushes to the remote if the remote does not have commits that the local branch doesn't have? The "compare and swap" mentioned by torek in the comments and in his other answer is further illustrated by the sources of Git itself. Looking for an answer drawing from credible and/or official sources. I'm sure you looked at the docs but there might be some more wordy explanation contained in here: Its unnecessary in most circumstances but will save you lots of headache if you happen to overwrite something that another person contributed to remote. A lot of teams at my company use -force-with-lease as the default option for a fail-safe. I just think of -force-with-lease as the option to use when I want to make sure I don't overwrite any teammates code. Obviously if there are additional commits in remote then the values won't be the same. If it doesn't have the same value- it indicates a change that someone else made to the remote branch while you were working on your code and thus will not overwrite any code. If the remote branch has the same value as the remote branch on your local machine- you will overwrite remote. I think your general idea surrounding the command is correct. ![]() It ensures you do not overwrite someone elses work by force pushing. force-with-lease is a safer option that will not overwrite any work on the remote branch if more commits were added to the remote branch (by another team-member or coworker or what have you). Force overwrites a remote branch with your local branch. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |