1. 安装git-for-windows
- 到git-for-windows的github下载git for windows
- 安装git for windows,全部默认即可
2. 编写工程文件
编程一个工程
test\
,注意要写.gitignore
文件D:\develop\test λ touch test.py D:\develop\test λ touch .gitignore D:\develop\test λ touch README.md
3. 创建空的git仓库
在本地创建一个空仓库,此时这个仓库是空的,什么文件都没有
D:\develop\test λ git init Initialized empty Git repository in D:/develop/test/.git/
4. 本地配置git
假如只有一个远程git托管账号,则可以使用全局配置
--gloabl
,即所有git仓库的配置(如下是告诉git即将提交的文件和代码是哪个人写的)D:\develop\test λ git config --global user.name "your_github_name" D:\develop\test λ git config --global user.email "your_github_email" # 查看git的全局配置: D:\develop\test λ git config -l
假如有两个远程git托管账号,例如gitlab和github,可以使用局部配置
--local
,即当前git仓库的配置D:\develop\test λ git config --global user.name "your_github_name" D:\develop\test λ git config --global user.email "your_github_email" # 查看git的局部配置 D:\develop\test λ git config --local -l
5. 往仓库中添加(add)文件并提交(commit)
注意:commit整个工程之前,务必先写好.gitignore
D:\develop\test (master -> origin) λ git add * D:\develop\test (master -> origin) λ git commit -m "your commit messsage" [master (root-commit) 621b68f] your commit messsage 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 test.py
- 至此,在本地已可以使用git仓库来管理工程文件的代码