vs Git 本地服务器仓库配置

1、安装Git程序

Git 下载地址一icon-default.png?t=N7T8https://git-scm.com/download/winGit 下载地址二We bring the awesome Git VCS to Windowsicon-default.png?t=N7T8https://gitforwindows.org/

2、新建本地服务端仓库

2.1、新建文件夹,并创建仓库

在本地新建文件夹://本地服务器仓库

在服务器仓库文件夹 右键菜单,选择:Git GUI here

Create New Repository 创建新仓库,选择之前创建的文件夹

 自动生成 git 文件夹

 2.2、利用VS 2019 新建项目

位置选择仓库文件夹://本地服务器仓库

2.3、添加忽略文件 忽略无需上传的文件

添加忽略文件后项目的生成文件就不会出现在更改中,只需要提交修改后的代码即可

 编辑一下:确保下面几种文件夹/文件已添加忽略

.DS_Store
.vs/
bin/
Log/
log/
Temp/
obj/
*.pdb

 取消忽略文件的暂存,并提交

 

 添加忽略文件后项目的生成文件就不会出现在更改中,只需要提交修改后的代码即可

 3、克隆服务端仓库

新建项目时选择 克隆存储库

克隆完成后如下,然后我们打开解决方案

 

 修改后的文件会出现

 修改完成后 添加备注 提交 ,提交完成后推送到服务器。

 4、推送过程中如果出现错误

正在推送 master
Enumerating objects: 9, done.
Delta compression using up to 16 threads
Total 5 (delta 1), reused 0 (delta 0), pack-reused 0
Remote: Error: refusing to update checked out branch: refs/heads/master        
Remote: Error: By default, updating the current branch in a non-bare repository        
Remote: is denied, because it will make the index and work tree inconsistent        
Remote: with what you pushed, and will require 'git reset --hard' to match        
Remote: the work tree to HEAD.        
Remote: 
Remote: You can set the 'receive.denyCurrentBranch' configuration variable        
Remote: to 'ignore' or 'warn' in the remote repository to allow pushing into        
Remote: its current branch; however, this is not recommended unless you        
Remote: arranged to update its work tree to match what you pushed in some        
Remote: other way.        
Remote: 
Remote: To squelch this message and still keep the default behaviour, set        
Remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.        
To A:\本地服务器仓库
Error: failed to push some refs to 'A:\本地服务器仓库'

修改服务端git//Config文件 添加下面代码,再次推送即可成功。

[receive]
	denyCurrentBranch = warn

5、 重新配置忽略文件

如果在第一次提交后发现忘记添加某项忽略文件,之后再修改忽略文件发现不起作用,那么我们就需要重新更新一下忽略文件

5.1、待忽略文件较多时

服务端文件夹右键-》选择Git Bash Here,调出Git控制台执行以下指令,完成后看,客户端需要重新克隆项目。

待忽略文件较多 全部重置

1. git rm -r --cached .     

2. git add .

3. git commit -m "update .gitignore"

5.2、待忽略文件较少

逐个移出忽略文件,然后更新。客户端可以自己操作完成,忽略不需要提交的文件。

待忽略文件较少
1. git rm -r --cached  不需要跟踪的文件名     

2. git add .

3. git commit -m "update .gitignore"

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

James.TCG

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值