有两种方式获得Git项目仓库,一是将现有项目或者说文件夹下面的所有文件导入到 Git 中,还有一种是从一个服务器克隆一个现有的 Git 仓库,这篇文章主要记录第一种方式的具体过程。
前提
-
安装好 Git
-
注册 gitlab ,建立好仓库
-
配置好 SSH keys
GitLab and SSH keys:The SSH protocol provides this security and allows you to
authenticate to the GitLab remote server without supplying your
username or password each time.
具体步骤
-
命令行切换至目标文件夹(项目所在地):
cd xxx
-
初始化仓库:
git init
这个步骤会生成名为.git
的子目录 -
跟踪目标文件,将其纳入版本控制:
git add .
(跟踪所有文件夹和文件)或者git add <target file>
(跟踪目标文件夹或者文件) -
将更改记录提交到存储库。:
git commit -m "initial project ve