How to switch back to 'master' with git?

前端 未结 5 626
无人共我
无人共我 2021-01-30 02:43

I have made my first commit; then created a branch (let\'s say branch1).

In this branch I\'ve created a directory \'example\' and commited. In GitHub I see my new branch

相关标签:
5条回答
  • 2021-01-30 03:12

    According to the Git Cheatsheet you have to create the branch first

    git branch [branchName]
    

    and then

    git checkout [branchName]
    
    0 讨论(0)
  • 2021-01-30 03:13

    Will take you to the master branch.

    git checkout master

    To switch to other branches do (ignore the square brackets, it's just for emphasis purposes)

    git checkout [the name of the branch you want to switch to]

    To create a new branch use the -b like this (ignore the square brackets, it's just for emphasis purposes)

    git checkout -b [the name of the branch you want to create]

    0 讨论(0)
  • 2021-01-30 03:20

    For deleting the branch you have to stash the changes made on the branch or you need to commit the changes you made on the branch. Follow the below steps if you made any changes in the current branch.

    1. git stash or git commit -m "XXX"
    2. git checkout master
    3. git branch -D merchantApi

    Note: Above steps will delete the branch locally.

    0 讨论(0)
  • 2021-01-30 03:26

    You need to checkout the branch:

    git checkout master
    

    See the Git cheat sheets for more information.

    Edit: Please note that git does not manage empty directories, so you'll have to manage them yourself. If your directory is empty, just remove it directly.

    0 讨论(0)
  • 2021-01-30 03:31

    I'm trying to sort of get my head around what's going on over there. Is there anything IN your "example" folder? Git doesn't track empty folders.

    If you branched and switched to your new branch then made a new folder and left it empty, and then did "git commit -a", you wouldn't get that new folder in the commit.

    Which means it's untracked, which means checking out a different branch wouldn't remove it.

    0 讨论(0)
提交回复
热议问题