当前位置: 首页 > Linux, tips > 正文

github fast-forwards 问题处理

修改了一下 fence_ssh agent,准备提交到github上去

    klwang@klwang-E6420:~/My_Dev/misc$ 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:   fence_ssh
    #
    no changes added to commit (use "git add" and/or "git commit -a")

觉得没有改什么大的问题,只是一些拼写错误,就用了 –amend 选项

    klwang@klwang-E6420:~/My_Dev/misc$ git commit -a --amend
    [master 006d0e7] modify pacemaker.conf modify fence_ssh
     3 files changed, 57 insertions(+), 66 deletions(-)
     rewrite cluster.conf (98%)

向上push的时候,就出现了 fast-forwards 的问题

    klwang@klwang-E6420:~/My_Dev/misc$ git push
    Password: 
    To https://wklxd@github.com/wklxd/misc.git
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'https://wklxd@github.com/wklxd/misc.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.

悲催了,找了一些资料,说是github上已经有相应文件,为了确保不丢失版本,github要求我将上面的文件merge下来后才可以push

    klwang@klwang-E6420:~/My_Dev/misc$ git pull
    Password: 
    You asked me to pull without telling me which branch you
    want to merge with, and 'branch.master.merge' in
    your configuration file does not tell me, either. Please
    specify which branch you want to use on the command line and
    try again (e.g. 'git pull <repository> <refspec>').
    See git-pull(1) for details.

    If you often merge with the same branch, you may want to
    use something like the following in your configuration file:

        [branch "master"]
        remote = <nickname>
        merge = <remote-ref>

        [remote "<nickname>"]
        url = <url>
        fetch = <refspec>

    See git-config(1) for details.

按照要求设置一些变量

    klwang@klwang-E6420:~/My_Dev/misc$ git config branch.master.remote origin
    klwang@klwang-E6420:~/My_Dev/misc$ git config branch.master.merge refs/heads/master  

再次pull一下

    klwang@klwang-E6420:~/My_Dev/misc$ git pull
    Password: 
    Auto-merging fence_ssh
    Merge made by recursive.

ok,看一下状态

    klwang@klwang-E6420:~/My_Dev/misc$ git status
    # On branch master
    # Your branch is ahead of 'origin/master' by 2 commits.
    #
    nothing to commit (working directory clean)

最终,完成push操作

    klwang@klwang-E6420:~/My_Dev/misc$ git push
    Password: 
    Counting objects: 8, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (4/4), done.
    Writing objects: 100% (4/4), 555 bytes, done.
    Total 4 (delta 2), reused 0 (delta 0)
    To https://wklxd@github.com/wklxd/misc.git
       1eba90b..2ea4e85  master -> master

好了,大功告成

    分享到:

本文固定链接: http://klwang.info/deal-with-github-fast-forwards-error/ | 数据库|Linux|软件开发

该日志由 klwang 于2013年09月21日发表在 Linux, tips 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: github fast-forwards 问题处理 | 数据库|Linux|软件开发
关键字: , ,

github fast-forwards 问题处理:等您坐沙发呢!

发表评论

*
快捷键:Ctrl+Enter