this post was submitted on 31 Jan 2024
220 points (98.7% liked)
Git
2909 readers
1 users here now
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Resources
Rules
- Follow programming.dev rules
- Be excellent to each other, no hostility towards users for any reason
- No spam of tools/companies/advertisements. It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.
Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
And what this graphic fails to discuss is that all these methods should be done BEFORE pushing. Once pushed, then the hashes are set and if you do any squashing, fixuping, etc, then you are rewriting hashes (and history) — and possibly orphaning other developers local copy.
wait what
could this be why I've failed to understand this topic on several occasions? I don't remember anything about push timing.
before you push what specifically?
And what if you accidentally push too soon?
The moment you push your changes to origin, other developers can then pull them. If you intend to squash or fixup commits, then you should do so after committing to your local git, but before you push to origin.
Once you push to origin, the commit hashes from your local branch become what origin has, and then those commit hashes are now possibly on another developer computer after they pull.
If you do a squash or a fixup, the existing commits are effectively rewritten into a new commit with a new hash so the developers who happened to pull what you previously pushed now have their HEAD pointing to a hash that no longer exists — thus orphaning.