Git 如何撤消提交,放入新分支,然后执行PR?
我有一个Git 如何撤消提交,放入新分支,然后执行PR?,git,Git,我有一个master分支,该分支仅受PR的push保护 我在大师上漫不经心地说: git add . git commit -m "bunch of changes" 但是我推到了分支,被拒绝了,因为分支受到了保护。 我如何回溯、保留我的更改以及进行PR git reset HEAD~ git checkout -b "name-of-new-branch" git -am "my fancy new commit" git push origin "name-of-new-branch"
master
分支,该分支仅受PR的push保护
我在大师
上漫不经心地说:
git add .
git commit -m "bunch of changes"
但是我推到了分支,被拒绝了,因为分支受到了保护。
我如何回溯、保留我的更改以及进行PR
git reset HEAD~
git checkout -b "name-of-new-branch"
git -am "my fancy new commit"
git push origin "name-of-new-branch"
重置头~将撤消上次提交。Checkout-b创建一个新分支并将其签出,然后您只需在那里添加和提交您的更改并推送
master
分支的最后一次提交
$ git reset --soft HEAD~1 # undo the last commit and keep the changes in working tree
$ git checkout -b feature # create and checkout to new 'feature' branch
$ git add -A # add the changes
$ git commit -m 'message' # commit
$ git push origin HEAD # push to remote 'feature' branch
功能
),然后添加、提交并推送到远程功能
分支
$ git reset --soft HEAD~1 # undo the last commit and keep the changes in working tree
$ git checkout -b feature # create and checkout to new 'feature' branch
$ git add -A # add the changes
$ git commit -m 'message' # commit
$ git push origin HEAD # push to remote 'feature' branch
feature
分支创建一个PR
$ git reset --soft HEAD~1 # undo the last commit and keep the changes in working tree
$ git checkout -b feature # create and checkout to new 'feature' branch
$ git add -A # add the changes
$ git commit -m 'message' # commit
$ git push origin HEAD # push to remote 'feature' branch
备选方案:
功能
)并将功能
分支推到远程
$ git checkout -b feature
$ git push origin HEAD
master
分支并撤消上次提交
$ git checkout master
$ git reset --hard HEAD~1
Or, (reset the local 'master' with 'origin/master')
$ git checkout master
$ git fetch origin
$ git reset --hard origin/master
现在,从
功能
分支创建PR。只需从源代码/主代码
提取PR,然后重新基于最新提交。可能重复
$ git reset --soft HEAD~1 # undo the last commit and keep the changes in working tree
$ git checkout -b feature # create and checkout to new 'feature' branch
$ git add -A # add the changes
$ git commit -m 'message' # commit
$ git push origin HEAD # push to remote 'feature' branch