VS2017下使用Git遇到的问题
我在使用最新版的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发现如下方法
git rm [path_and_filename] --cached //该命令将永远不想签入的文件从索引(index)中移除,如果不想这个文件存在磁盘上,可以使用git rm [path_and_filename] --force
- 将操作后的文件(此时已经是staged)提交就好了
Ps:
- .gitignore 是最先想到的方法,但是也不行,不过SO上有人貌似是可以的,如下:
# Visual Studio 2015 cache/options directory
.vs/
- 微软官档:
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 <file>
3. Commit the removal of the file and the updated .gitignore to your repo.
参考地址:
- .gitignore for C#: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore#L28
- https://stackoverflow.com/questions/45016619/what-is-the-storage-ide-file-beneath-my-visual-studio-solution-folder-and-wha
- https://stackoverflow.com/questions/45802083/visual-studio-2017-15-3-0-git-changes-include-storage-ide-even-though-vs-in
- https://docs.microsoft.com/en-us/vsts/git/tutorial/ignore-files?tabs=visual-studio
Ps2: 加一个描述更详细的说明

参考地址:http://www.pfeng.org/archives/840
1. 关于将已经ignore的文件(夹)重新加入跟踪里面
重新添加已经被忽略过的文件(夹)
重新添加已经被忽略过的文件时,我们仅仅使用git add是不行的,因为git仓库中根本没有那个文件,这时候我们需要加上-f参数来强制添加到仓库中,然后在提交。比如上面设置了忽略排除的文件TokenGuard.php我们需要重新加入
git add -f [文件(夹)名]
然后在commit和push就行了
2. 关于VS中经常出现的error: Your local changes to the following files would be overwritten by merge:
error: Your local changes to the following files would be overwritten by merge:
意思是我本地上新修改的代码的文件,将会被git服务器上的代码覆盖;我当然不想刚刚写的代码被覆盖掉,看了git的手册,发现可以这样解决:
方法1:如果你想保留刚才本地修改的代码,并把git服务器上的代码pull到本地(本地刚才修改的代码将会被暂时封存起来)
git stash
git pull origin master
git stash pop
如此一来,服务器上的代码更新到了本地,而且你本地修改的代码也没有被覆盖,之后使用add,commit,push 命令即可更新本地代码到服务器了。
方法2、如果你想完全地覆盖本地的代码,只保留服务器端代码,则直接回退到上一个版本,再进行pull:
git reset --hard
git pull origin master
注:其中origin master表示git的主分支。
VS2017下使用Git遇到的问题的更多相关文章
- VS2017 下使用 git. git服务器使用gitblit
注意事项: 创建的GIT不要包括有中文, 不然会不成功的..... gitblit安装及配置及客户端下载略过...... 可参考: https://www.cnblogs.com/jeremylee ...
- VS2017中使用Git进行版本控制
简单介绍在VS2015下使用Git来管理项目 1. VS2017启用Git源代码管理插件 第一步,打开vs: 第二步,打开[团队资源管理器]: 第三步,选择团队管理器选项卡下的[连接]页面,点击[克隆 ...
- 在Centos下搭建git并可以通过windows客户端访问
亲测在本地虚拟机和远程服务器上无问题,如有不懂请留言. 注意事项:以下所有操作是在root权限下操作的.1.Centos服务器版本centos6.5 2.首先安装git,使用yum在线安装 yum i ...
- ***Linux下使用git命令及github项目
在linux下搭建git环境1.创建Github账号,https://github.com2.Linux创建SSH密钥: ssh-keygen ##一直默认就可以了 3.将公钥加入到Github账户 ...
- Linux下安装Git
Ubuntu12.04中默认没有安装Git.需要自行安装. 1. 安装Git 1.1 Ubuntu12.04下 可以使用apt-get方式安装,也可以下载源代码安装[1],我们这里使用apt-git安 ...
- Windows 环境下配置 git bash 的 HOME 默认路径
0.引 在 windows 下安装 git 之后, git 默认的HOME和~路径一般都是C:\Users\用户名,每次得用命令切换到常用的Repository下,此操作重复而没有意义.为了修改默认路 ...
- windows下安装git & 在git@OSC上推送代码
第一部分 windows下安装git 1.下载最新版本的git:直接百度“git”,如图所示,点击立即下载. 也可以直接在官网下载最新版本的git:http://www.git-scm.com/dow ...
- Windows下搭建Git开发环境
Windows下搭建Git开发环境主要有以下三种方法: 1,VS,vs2013和vs2015中已经集成了git插件了 2,msysGit+TortoiseGit 3,msysGit+SourceTre ...
- Android 源码获取-----在Windows环境下通过Git得到Android源代码
在学习Android的过程中,深入其源代码研究对我们来说是非常重要的,这里将介绍如何通过在Windows环境下使用Git来得到我们的Android源代码. 1.首先确保你电脑上安装了Git,这个通过 ...
随机推荐
- vue项目中遇到的那些事。
前言 有好几天没更新文章了.这段实际忙着做了一个vue的项目,从 19 天前开始,到今天刚好 20 天,独立完成. 做vue项目做这个项目一方面能为工作做一些准备,一方面也精进一下技术. 技术栈:vu ...
- kali中的webshell工具--webacoo
webacoo webshell其实就是放置在服务器上的一段代码 kali中生成webshell的工具 WeBaCoo(Web Backdoor Cookie) 特点及使用方法 类终端的shell 编 ...
- 002 requests的使用方法以及xpath和beautifulsoup4提取数据
1.直接使用url,没用headers的请求 import requests url = 'http://www.baidu.com' # requests请求用get方法 response = re ...
- Interface Comparable<T>
Interface Comparable<T> : 该接口对实现它的每个类的对象强加一个整体排序. 这个排序被称为类的自然排序 ,类的compareTo方法被称为其自然比较方法 . 参数 ...
- python3随机数函数
随机数函数 choice(seq) 从序列的元素中随机挑选一个元素,比如random.choice(range(10)),从0到9中随机挑选一个整数. randrange ([start,] stop ...
- zabbix监控ssl证书到期时间
监控脚本 cat ssl_check.sh #!/bin/bash # #获取ssl证书的过期时间 #menghao #获取证书的有效时间 time=$(echo | openssl s_client ...
- SharpMap在web上的应用
最近公司用SharpMap做了一个做桌面程序,它是一个开源的Gis项目,功能还可以,最大的特点就是简单易用,这里介绍下怎么在web下使用: 这次我们根据demo先了解一下如何show一个地图.这是最基 ...
- 【转】Setting up SDL 2 on Visual Studio 2010 Ultimate
from: Lazy Foo'Productions - Setting up SDL 2 on Visual Studio 2010 Ultimate 1)First thing you need ...
- AngularJS指令基础(一)
AngularJS指令基础(一) 1.什么是指令:粗暴的理解就是,自定义HTML标签.专业理解是指,angularJS扩展具有自定义功能的HTML元素的途径. 2.什么时候用到指令:需求是变化的.多样 ...
- Python数据可视化-seaborn库之countplot
在Python数据可视化中,seaborn较好的提供了图形的一些可视化功效. seaborn官方文档见链接:http://seaborn.pydata.org/api.html countplot是s ...
