1、注册https://git.oschina.net/
2、注册好后,创建一个测试项目,如下图:
点击创建,如下:
上面的红框中的地址下面会用到。
3、git初始化设置
在本地电脑要安装git,打开git命令行输入框,输入下面两句:
git config --global user.name “你的姓名”
git config --global user.email ”你的邮箱“
git config --global user.email ”你的邮箱“
4、在本地项目文件夹根目录git init命令

执行命令后会看到项目文件夹里多了.git这个隐藏文件夹。
5、在visual studio中把解决方案添加到源码管理中
在vs中打开“团队资源管理器”,点“添加”,选择你的项目文件,如下图:

选择文件后,点“确定”,再点“添加”,即可。
也可以在“解决方案资源管理器”中右键解决方案,选择“将解决方案添加到源代码管理”,一样可以。
6、添加gitignore文件
有的文件是不需要上传到服务器的,设置gitignore文件可以过滤你不需要上传的文件,微软已写了默认值,只添加即可。
在“团队资源管理器”的主页中,选择“设置”,如下图:

在出现的界面中选择“存储库设置”,再然后如下:

点击“添加”即可。
7、提交本地源码
在“团队资源管理器”的主页中,选择“更改”,如下图:

红线框内都是需要提交的。
输入提交信息后即可提交,如下图:

提交方式选择“全部提交并推送”,这样可以一键提交到远程服务器(码云-开源中国的服务器),选择“全部提交并推送”会出现如下界面(第一次提交是这样):

选择“开始使用”后,如下:

发布即可,再次提交则不用再提示输入url地址。
注:
工作中要用git来管理源码,第一次使用,特记录下来,以备后看,因为是第一次用,只知操作步骤,而不知其所然,望谅解!