github创建repo,本地导入git项目到github

  一般地,在注册好github账号之后,你需要做的事情就是在github上创建一个repo,该repo将成为你的origin(central)repo,随后你就可以将本地的项目git repo导入到这个github repo中。这样做的好处就是github免费成为了一个供你或你的团队工作学习的一个公共库。

在这里简单列出这个过程中所使用到的git命令:

git config --global color.status auto第一次本地使用git的话,可能要用到它,这样就可以以彩色的方式展示你的git命令输出了;

git config --global user.email "your-email-id@example.com"
git config --global user.name "Your-Github-UserName"

上述命令将配置将来github中需要的认证授权及版权信息。

git remote add origin https://github.com/xxx/gittest.git 

git remote set-url origin https://Your-Github-UserNAme@github.com/Your-Github-UserNAme/REPO-NAME 
上面两条比较关键,否则可能出现403 forbidden错误

git remote -v                                               
origin  https://xxx@github.com/xxx/gittest.git (fetch)                                  
origin  https://xxx@github.com/xxx/gittest.git (push) 
git push -u origin master
 
原文地址:https://www.cnblogs.com/kidsitcn/p/4513134.html