git pull 時出現 error: Your local changes to the following files would be overwritten by merge的解決辦法

來源:互聯網
上載者:User

The most useful commands you will want to learn are

  • clone
  • status
  • pull
  • commit
  • push
  • gitk
  • stash
  • log
  • checkout
% git clone ssh://antportal.com:22/var/lib/git/rndtaxcredit.gitCloning into rndtaxcredit...remote: Counting objects: 1571, done.remote: Compressing objects: 100% (1434/1434), done.remote: Total 1571 (delta 907), reused 196 (delta 88)Receiving objects: 100% (1571/1571), 4.59 MiB | 1.09 MiB/s, done.Resolving deltas: 100% (907/907), done.

Stashing when pull doesn't work

% git pull...error: Your local changes to the following files would be overwritten by merge:    webfront/app/views/Projects/index.html    webfront/app/views/main.htmlPlease, commit your changes or stash them before you can merge.

In those cases, you want to stash

% git stashSaved working directory and index state WIP on master: 11f6d51 merge changesHEAD is now at 11f6d51 merge changes

Then you pull...

rndtaxcredit/rndtaxcredit % git pull...5 files changed, 61 insertions(+), 69 deletions(-)

And finally you stash pop

% git stash pop....Dropped refs/stash@{0} (865bf3eef6b7752cff098dbf3dd20b2ffebb02f7)

git checkout is useful for switching between branches. A best practice, in conjunction with working with an issue tracker such as jira, is to
create branches for each issue.

git checkout -b i777

where, issue 777 would be the issue number for this issue. This enables a convenient coupling between the name of your branches and the issues you are working on. "git checkout -b some_branch" is equivalent to the two commands "git branch some_branch" and "git
checkout some_branch"

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.