上下文:我正在为master添加一个简单的功能.几分钟后,我意识到这不是那么简单,应该更好地进入一个新的分支.
这总是发生在我身上,我不知道如何切换到另一个分支并采取所有这些未经修改的更改与我离开主分支清洁.我想git stash && git stash branch new_branch应该只是完成它,但这就是我得到的:
~/test $ git status
# On branch master
nothing to commit (working directory clean)
~/test $ echo "hello!" > testing
~/test $ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: testing
#
no changes added to commit (use "git add" and/or …Run Code Online (Sandbox Code Playgroud) Git中的Sign Off功能有什么意义?
git commit --signoff
Run Code Online (Sandbox Code Playgroud)
我什么时候应该使用它,如果有的话?
我很确定我在一个流行的Git项目中看到某个地方的分支有一个像"feature/xyz"这样的模式.
但是当我尝试使用斜杠字符创建一个分支时,我收到一个错误:
$ git branch labs/feature
error: unable to resolve reference refs/heads/labs/feature: Not a directory
fatal: Failed to lock ref for update: Not a directory
Run Code Online (Sandbox Code Playgroud)
同样的问题(我最初的尝试):
$ git checkout -b labs/feature
Run Code Online (Sandbox Code Playgroud)
如何使用斜杠字符在Git中创建分支?
当我尝试推动我提交的更改时,我收到以下错误...
git.exe push -v --progress "origin" iteration1:iteration1
remote: *********************************************************************
To ssh://git@mycogit/cit_pplus.git
! [remote rejected] iteration1 -> iteration1 (pre-receive hook declined)
error: failed to push some refs to 'ssh://git@mycogit/cit_pplus.git'
Run Code Online (Sandbox Code Playgroud)
这是怎么回事?
可能重复:
Git - 创建一个包含当前更改的分支
我在我的项目上做了很多工作,我意识到应该在另一个分支上完成.如果我现在创建一个分支,我的当前更改是否需要签入,或者在创建新分支时是否会被擦除?我对GIT很新,我只是想避免犯新手的错误.
我是git的新手,并试图围绕分支的工作方式.根据文档git checkout
更新工作树中的文件以匹配索引或指定树中的版本.如果>没有给出路径,git checkout也会更新HEAD以将指定的分支设置为>当前分支.
所以据我所知,我工作的目录中的文件(我执行git init的文件)应该根据我所在的分支进行更改.我很困惑,因为当我在分支之间切换时不会发生这种情况.在切换分支之前我正在编辑的编辑存在于我切换到的分支中.我做错了什么或git checkout不能这样工作,我只是误解了文档?
我在
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
Run Code Online (Sandbox Code Playgroud)
在我的本地主分支中进行并进行一些更改之后的状态.
如何将本地更改添加到新分支中?
我期望的结果是:local/master与origin/master同步,并且我有一个本地分支,其中包含两个提交.