Git is a powerful tool I use every single day. Up until a few months ago I only used the bare minimum to get my job done. When I moved to a diffe...
For further actions, you may consider blocking this person and/or reporting abuse
Great post!
Sometimes I need checkout to specific tag. Here's how you can do that:
git fetch --all --tags
git checkout tags/<tag>
You can also create a new branch for the tag:
git checkout tags/<tag> -b <branch-name>
I don't often use tag, but I really like the use cases for tagging version releases. If you ever need to pick something from a specific version, you can just hop into the tag!
Great addition :)
Exactly!
It's useful for debugging purposes, when different versions of the project are deployed to different servers, and you're getting bug report which might be already fixed in the new version. 😀
Since Git 2.23.0, you can use
git restore
. It's a huge improvement over the sometimes-misleading checkout command.In what way would you say
checkout
is misleading? I'd love to dive into that 😄I did a quick search for
git restore
and it seems it's still experimental, so I wonder if it's a good idea to advice that. I'll definitely try it out the next time I need it, tho!Sorry for the confusion.
I said "misleading" in the sense that it's used for various purposes - Using
checkout
you can:-b
flag)Now, you can use
git switch
andgit restore
to avoid such confusion with thecheckout
command -switch -c
creates a branch,switch
switches to a branch, andrestore
is for reverting.Yeah that makes more sense! I get what you are saying and I agree that having the specific command is much clearer. I'm still a little thrown off by the experimental part of the command. All in due time I suppose :)
This one is golden, thanks :)
git commit --amend --no-edit
I agree.. this one is golden. And I am sure, now I am going to use this a lot.
The most enlighting command I find out not so long ago is
git add -p ...then whatever...
it let you add single chunks of files to stage areas.It is a godsend when working on complex problems. You can add related chunks in the same commit between files. So commits are still atomic and related to a single change.
Your list is well-assembled! Thanks!
Thank you very much :)