Git 常用命令

# 创建秘钥
$ cd ~/.ssh
$ ssh-keygen -t rsa -C "mail@example.com"
# 查看秘钥并把秘钥复制粘贴到账号设置中
$ cat ~/.ssh/id_rsa.pub
# 测试这个秘钥是否配置正确
$ ssh -T git@git.coding.net

# 设置全局用户名和邮箱
$ git config --global user.name "example"
$ git config --global user.email "mail@example.com"

# 在本地初始化一个仓库
$ git init
# 把仓库和远程仓库关联
$ git remote add origin git@git.coding.net:example/code.git
# 从远程仓库中拉取
$ git pull origin master
# 添加本地所有变更的文件到缓存区
$ git add .
# 提交到本地仓库
$ git commit -m "first commit"
# 推送到远程仓库
$ git push origin master