
I have been usingGit version control for several years. I probably should have mastered it by now, but that has not happened. I know just enough commands and options to bedangerous. Every now and then, I will learn something new and smile.
One example is thegit checkout
command. I have used this command countless times to switch back and forth between different branches in my Git repos. For example, here is a repo withmaster
anddevelop
branches:
$ git checkout developSwitched to branch'develop'$ git checkout masterSwitched to branch'master'Your branch is up todatewith'origin/master'.$ git checkout developSwitched to branch'develop'$
I have been switching Git branches this way foryears. But this week, I learnedgit checkout -
. This version of the command switches to thelast branch that you were on:
$ git checkout developSwitched to branch'develop'$ git checkout -Switched to branch'master'Your branch is up todatewith'origin/master'.$ git checkout -Switched to branch'develop'$ git checkout -Switched to branch'master'Your branch is up todatewith'origin/master'.$
Mind blown! Thegit checkout -
command is a blessing. It is so much easier, especially when your Git branches have long names. This would have saved me lots of typing over the years 😩. Oh well, better late than never!
If you already know aboutgit checkout -
, great. If not, I hope it makes your Git life easier.
Thanks for reading. 😃
Follow me on Twitter@realEdwinTorres
for more programming tips and help.
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse