git使用

git多账户设置:

  1. ssh-keygen -t rsa -C "user1@email.com"

  2. 登录Gitee,进入【Settings】-【SSH and GPG keys】

  3. 测试该用户的SSH密钥是否生效:

    ssh -T git@gitee.com
    

    另一个账户基本相同

在.ssh目录下创建一个config文本文件

# 配置user1 
Host user1.github.com
HostName github.com
IdentityFile C:\Users\lingh\.ssh\id_rsa
PreferredAuthentications publickey
User user1

# 配置user2
Host user2.github.com
HostName github.com
IdentityFile C:\Users\lingh\.ssh\id_rsa2
PreferredAuthentications publickey
User user2

为各仓库单独配置用户名和邮箱

git config user.name "user1"
git config user.email "user1@email.com"

git代码提交

1. 登陆github,创建git仓库。记此git仓库的地址为[github_repository_url],例如git仓库的地址:https://github.com/galian123/nodejs_http_server
2. 在本地的工程目录执行git init,此工程目录是要提交到github的。git init是将本地的工程目录作为本地的git仓库。 
注:下面的git命令都是在此工程目录中执行的
3. 执行git add .,将本地的工程目录(包括子文件)都添加到本地的git仓库
4. 执行git commit -m "write some comment",将本地的工程提交到本地的git仓库
5. 执行git remote add origin [github_repository_url],将本地仓库与github上的仓库关联起来。 
可以通过git remote -v查看github上的仓库地址。
6. 执行git pull origin master同步github仓库和本地仓库
7. 执行git push origin master将本地工程提交到github

git提交. https://zhuanlan.zhihu.com/p/58400264

git多账户. https://blog.csdn.net/q13554515812/article/details/83506172?utm_medium=distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromMachineLearnPai2~default-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromMachineLearnPai2~default-1.control

原文地址:https://www.cnblogs.com/gongyanzh/p/14985982.html