Answer a question

I've been working on a website using Visual Studio Code. I've branched off of main this weekend on a desktop. I pushed all of the changes to the remote.

Later on my laptop, where I thought I had the main branch cloned, when I tried running the command git checkout, but it didn't find anything branches. I'm still new to using Git so I'm sure I've done something wrong, but don't know what. What am I doing wrong?

Answers

Here are the things you should consider before using git checkout:

  • Check if you changed something, you can do that by the command: git status
  • If you did changed something, you can either commit or stash the changes.
    • stash removes all your changes made.
    • commit adds all your changes (affects only your branch).
  • If you choose to remove the changes, you can simply use the command: git stash
  • If you choose to add the changes. Do the following command:
    • git add . adds all your changes.
    • git commit -m 'Hey I changed something' commits the changes to your `local branch

After that, you can now use git checkout. Note, by the time you checkout, all the changes you committed under your branch will be pushed to where you checked out.

I hope it helps.

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐