1. 程式人生 > >Git工作筆記004---torisegit使用時Updates were rejected because the tip of your current branch i

Git工作筆記004---torisegit使用時Updates were rejected because the tip of your current branch i

   JAVA技術交流QQ群:170933152     

 

因為要跟別的公司一塊合作開發,我們用svn他們用git,現在又得用git

 我在提交的時候:報如下錯誤:

git.exe push --progress "origin" master:master

To http://120.92.190.195:9182/smart-community/sc-front.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'http://120.92.190.195:9182/smart-community/sc-front.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


git did not exit cleanly (exit code 1) (1547 ms @ 2018/10/29 17:45:30)

首先他們說在:

E:\scgit\sc-front\.git\config 這個檔案中

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[remote "origin"]
    url = http://120.92.190.195:9182/smart-community/sc-front.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

新增下面這部分
[http]
    postBuffer = 5242880000

 

解決方案:我採用下面的第二種方法解決的,並且沒有用torisegit,而是用的命令,執行的下面2那個命令,我先執行了1,又執行了2,就好了
----------

剛建立的github版本庫,在push程式碼時出錯:

$ git push -u origin master
To [email protected]:******/Demo.git
 ! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '

[email protected]:******/Demo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

網上搜索了下,是因為遠端repository和我本地的repository衝突導致的,而我在建立版本庫後,在github的版本庫頁面點選了建立README.md檔案的按鈕建立了說明文件,但是卻沒有pull到本地。這樣就產生了版本衝突的問題。

有如下幾種解決方法:

1.使用強制push的方法:

$ git push -u origin master -f 

這樣會使遠端修改丟失,一般是不可取的,尤其是多人協作開發的時候。

2.push前先將遠端repository修改pull下來

$ git pull origin master

$ git push -u origin master


3.若不想merge遠端和本地修改,可以先建立新的分支:

$ git branch [name]

然後push

$ git push -u origin [name]

------------------------------------------