Git的基本使用方法

全局设置

1
2
$ git config --global user.name "你的名字或昵称"
$ git config --global user.email "你的邮箱"

方法一:克隆远程仓库

1
2
3
4
5
$ git clone https://gitee.com/用户个性地址/HelloGitee.git #将远程仓库克隆到本地
$ git init
$ git add . #将当前目录所有文件添加到git暂存区
$ git commit -m "my first commit" #提交并备注提交信息
$ git push -u origin master #将本地提交推送到远程仓库

方法二:创建本地仓库

1
2
3
4
5
6
$ mkdir as-shown-in
$ cd as-shown-in
$ git init
$ git commit -m "first commit"
$ git remote add origin https://gitee.com/night-scholar/as-shown-in.git
$ git push -u origin master

方法三:已有仓库

1
2
3
cd existing_git_repo
git remote add origin https://gitee.com/night-scholar/as-shown-in.git
git push -u origin master