V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
sd4399340
V2EX  ›  问与答

关于GIT,求教

  •  
  •   sd4399340 · Dec 16, 2011 · 4979 views
    This topic created in 5249 days ago, the information mentioned may be changed or developed.
    遇到这么一种情况,不知道该怎么办,求教~

    本地和服务器处于同一个commit,然后我本地做了一些改动,commit了一下,使用 --amend,commit message没有动,然后此时我push,报错,大概就是本地和服务器不同步,然后我pull了一下,出现一些文件无法自动合并。这是我git status,出现:

    # On branch master
    # Your branch and 'origin/master' have diverged,
    # and have 1 and 1 different commit(s) each, respectively.
    #
    # Unmerged paths:
    # (use "git add/rm <file>..." as appropriate to mark resolution)
    #
    # both modified: xxxx
    # both modified: xxxx
    # both modified: xxx
    # both added: xxx
    #
    no changes added to commit (use "git add" and/or "git commit -a")

    我也不记得究竟改过什么文件了,怕会不会我的改动被merge覆盖掉,还有现在应该怎么办。。。
    4 replies    1970-01-01 08:00:00 +08:00
    kongruxi
        1
    kongruxi  
       Dec 16, 2011
    已经push了就不要做amend或者rebase操作,如果服务端的库是多人共享的,那是灾难性的。

    如果只是你只是一个人用,git push -f
    xi4oh4o
        2
    xi4oh4o  
       Dec 16, 2011
    手动解决冲突 git add it
    sd4399340
        3
    sd4399340  
    OP
       Dec 17, 2011
    解决了,原来冲突的内容都在源文件里,学习了。
    幸好是我一个人在用,我改了一下冲突的东西,重新提交了~
    lerry
        4
    lerry  
       Dec 17, 2011
    我也遇到过,我一般是只修改了一个文件,用编辑器打开那个文件,直接git commit -a 然后,自动合并就好了,然后再把编辑器里面的保存,再次提交
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2520 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 06:37 · PVG 14:37 · LAX 23:37 · JFK 02:37
    ♥ Do have faith in what you're doing.