In GIT, if I checkout a tag I'll get my working copy to that tag's reference, i.e. the code will represent what I had at that time. I'm I correct?
Now, if I do that, and modify my code and commit. Where is that commit going? Will it sort of 'auto-merge'? Meaning that if I push my commit, someone that clones the repo will also get the fix I did from the tag? Or otherwise, if I switch back to master, will I have the code modification available there?
The commit is still only stored locally. Only you have a reference to the modified version. If you want to make it available to others, you will also have to do a git push of your code to the given branch.
Your commits are branch-specific, meaning if you change branches after committing, your changes will not carry over. However, when you change back to the branch, the commit will still be there.
It will not "auto-merge". It is stored in the repository, referenced by HEAD directly. Usually the reference HEAD (the small file in .git, named HEAD) contains the name of the branch, which top-commit reference is updated with every commit. In you case it is a so called "detached HEAD".
You can always save the detached HEAD in a real branch reference: git branch something. Or just checkout another branch and forget about the commits, they will be cleaned up eventually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With