9
我目前正在开发一个项目,并在两个不同的位置使用机器来完成它。我为我正在工作的功能创建了一个分支,当我完成一些工作时,我修改了对该分支的提交并将其推送到服务器,以便我可以从我的另一台计算机上停下来。Git:推动修改的提交
当我尝试发送修改后的提交时,它拒绝了我的推送。我认为这是因为我推送了一个旨在摧毁功能分支的当前HEAD的提交。我通常只使用--force。
有没有更好的方法来做到这一点?
[email protected]:~/projects/myproject$ git pull origin topx
From heroku.com:myproject
* branch topx -> FETCH_HEAD
Already up-to-date.
[email protected]:~/projects/myproject$ git add app/models/reward.rb
[email protected]:~/projects/myproject$ git commit --amend
[topx 82a9880] Added topX reward
9 files changed, 106 insertions(+), 21 deletions(-)
rewrite app/views/ceo/_reward_criteria.html.erb (96%)
create mode 100644 public/javascripts/jquery.multiselect.min.js
create mode 100644 public/site/javascripts/jquery.multiselect.min.js
create mode 100644 public/stylesheets/jquery.multiselect.css
[email protected]:~/projects/myproject$ git push origin topx
To [email protected]:myproject.git
! [rejected] topx -> topx (non-fast-forward)
error: failed to push some refs to '[email protected]:myproject.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
我认为“不要使用修改”选项:不要在已发布的工作中使用它。在未发表的作品(本地/个人分支)上,你绝对应该使用它。 (如果你有一个以上的个人回购,那就意味着你会用'push-force'来转移你的工作,这很好。) – Cascabel 2010-10-19 13:20:50
非常感谢!现在我可以保证我的代码安全,提交日志清晰。 – 2015-10-13 13:11:45