Git使用Git

Git 多账号配置

2016-09-30  本文已影响110人  猿圆猿

问题描述

git是目前使用的非常广泛的一个开源的分布式版本控制系统,大部分公司都在使用,然后大家又有自己的Github账号。这样就会出现一个问题,比如:公司使用的是Gitlab,需要配置一个git账号,当我们需要提交自己的一些小程序到github上时,就会出现多账号配置的问题。

解决

在需要提交的目录下先执行以下代码

git config user.name "Your Name Here"
git config user.email your@email.com

意思就是此目录下使用这个用户名进行提交,就能正常提交到github上了。

下面是完整流程:

1.进入项目目录

cd ~/you project

2.初始化

git init

3.配置账号信息

git config user.name "Your Name Here"
git config user.email your@email.com

4.添加到git

git add .

5.提交到本地仓库

git commit -m "备注"

6.建立与github的连接

git remote add origin https://github.com/fccaikai/MaterialDesignLibrary.git

7.提交至github

git push -u origin master

参考:http://stackoverflow.com/questions/4220416/can-i-specify-multiple-users-for-myself-in-gitconfig

上一篇 下一篇

猜你喜欢

热点阅读