码迷,mamicode.com
首页 > 其他好文 > 详细

VS2017下使用Git遇到的问题

时间:2017-11-20 13:07:39      阅读:542      评论:0      收藏:0      [点我收藏+]

标签:问题   获取   blog   text   merge   epo   solution   ted   微软   

我在使用最新版的VS2017时,想获取服务器上最新代码,Fetch到了最新修改,但是在拉取代码的时候出现了问题

user@user-PC MINGW64 /d/demo/myrepos (dev-css)
$ git pull origin dev-css
From https://winleechina.visualstudio.com/_git/PartTimeJob
 * branch            dev-css    -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
        BaseSite/Code/.vs/BaseSite/v15/Server/sqlite3/storage.ide-shm
        BaseSite/Code/.vs/BaseSite/v15/Server/sqlite3/storage.ide-wal
        BaseSite/Code/.vs/BaseSite/v15/sqlite3/storage.ide-shm
        BaseSite/Code/.vs/BaseSite/v15/sqlite3/storage.ide-wal
Please commit your changes or stash them before you merge.
Aborting
Updating d568290..cf89950

user@user-PC MINGW64 /d/demo/myrepos (dev-css)
$ git status
On branch dev-css
Your branch is behind ‘origin/dev-css‘ by 8 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   BaseSite/Code/.vs/BaseSite/v15/Server/sqlite3/storage.ide-shm
        modified:   BaseSite/Code/.vs/BaseSite/v15/sqlite3/storage.ide-shm

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .gitattributes
        .gitignore

no changes added to commit (use "git add" and/or "git commit -a")

于是我采用常规套路(签入,或者撤销checkout) 都是失败,而且不能undo change其中两个文件storage.ide-shm/storage.ide-shm;

这个问题的最终结果就是导致我不能拉取最新代码。

好在在StackOverflow发现如下方法

  1. 技术分享图片
    text git rm [path_and_filename] --cached //该命令将永远不想签入的文件从索引(index)中移除,如果不想这个文件存在磁盘上,可以使用git rm [path_and_filename] --force

  2. 将操作后的文件(此时已经是staged)提交就好了

Ps:

  1. .gitignore 是最先想到的方法,但是也不行,不过SO上有人貌似是可以的,如下:

     # Visual Studio 2015 cache/options directory
     .vs/
  2. 微软官档:

    Permanently ignore changes to a file

    If a file is already tracked by Git, adding that file to your .gitignore is not enough to ignore changes to the file. You also need to remove the information about the file from Git‘s index
    These steps will not delete the file from your system. They just tell Git to ignore future updates to the file.+
    1. Add the file in your .gitignore.
    2. Run the following:

      git rm --cached

    3. Commit the removal of the file and the updated .gitignore to your repo.

参考地址:

  1. .gitignore for C#: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore#L28
  2. https://stackoverflow.com/questions/45016619/what-is-the-storage-ide-file-beneath-my-visual-studio-solution-folder-and-wha
  3. https://stackoverflow.com/questions/45802083/visual-studio-2017-15-3-0-git-changes-include-storage-ide-even-though-vs-in
  4. https://docs.microsoft.com/en-us/vsts/git/tutorial/ignore-files?tabs=visual-studio

VS2017下使用Git遇到的问题

标签:问题   获取   blog   text   merge   epo   solution   ted   微软   

原文地址:http://www.cnblogs.com/winleechina/p/7865175.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!