【问题标题】:Unable to create a branch on my local repo无法在我的本地仓库中创建分支
【发布时间】:2020-07-02 13:02:00
【问题描述】:

请把我当作 git 的初学者,因为我刚刚开始学习它。

我已经在我的机器上安装了 git,并使用“git init”命令启动了一个本地 git repo。

在 git 本地存储库中添加了几个文本文件并使用“git add”。命令我将新添加的文件添加到暂存区。

现在我想使用“git branch”命令检查当前分支,但它什么也没说,命令提示符也没有响应。 即使我也在尝试创建一个新分支,我也无法这样做。

谁能给我解释一下这里有什么问题

【问题讨论】:

  • 请将您与命令行的整个实际“对话”直接复制并粘贴到问题中。您可能处于某种编辑模式。
  • do : git status 并把结果放在这里

标签: git github git-branch


【解决方案1】:

如果你已经成功地用 git 初始化了你的项目,那么你可以运行下面的命令。

 1. git status // this command show which branch  you are right now and all changes files.

 2.git add . // this command add all chnages file to staging area
      or
   git add file_name // give complete file path which show after executing git status command

 You can check your  added file in staging area using command
 3. git status // you always run this command for cross check which branch  you are right now and all added files.

 Now commit your files using command
 4. git commit -m "commit message"

 if you want to push this branch code to remote repo, you can use 
 5. git push origin YOUR_CURRENT_WORKING_BRANCH_NAME 

 If you are working in any other branch than master. checkout master first then create your other branch.
 6. git checkout master 
 
 Now you can create and switch to that branch in one command using
 7. git checkout -b YOUR_DESIRE_BRANCH_NAME

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-02
    • 2021-04-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多