2015-09-15 30 views
0

我終於開始理解git的基礎知識,但我只是想確保我理解它的這個特定部分。安全地推入git而不是首先獲取? (或git pull)

我一直在使用Visual Studio中的git功能,所以我習慣於「同步」按鈕。啊。現在我正在從命令行做所有事情,但是我只想確定,當我向上推進主人時,我正在做正確的事情。我是唯一在遙控器上工作的開發人員,所以這是一個低風險的情況(相對來說)....但我應該在推動之前至少總是獲取git獲取?似乎我應該必須確保我推入一個遠程回購,我的本地回購更新到目前爲止。對?如果我推送和遠程/本地不同步會發生什麼?我收到錯誤嗎?

回答

1

在推動之前,您不必每次都進行提取/提取。如果你的推送與已經在遠程倉庫中的內容衝突,git會給你一個錯誤,如下所示:

$ git push 
To [email protected]:your/repository.git 
! [rejected]  master -> master (non-fast-forward) 
error: failed to push some refs to '[email protected]:your/repository.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. 
+0

感謝這個例子 – JzInqXc9Dg

0

git只會拒絕push如果您有不兼容的更改。

相關問題