参考网址:https://help.github.com/
1、在github上注册一个帐户,并登录
2、安装和配置git
sudo apt-get install git-core
git config --global user.name "Your Name Here"
git config --global user.email "your_email@example.com" //这里的email地址应该与你登录github的email账户地址保持一致
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=3600'
3、Generating SSH Keys (https://help.github.com/articles/generating-ssh-keys)
ssh-keygen -t rsa -C "your_email@example.com" //这里的email地址应该与你登录github的email账户地址保持一致
ssh-add ~/.ssh/id_rsa
成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的 key。
回到github,进入Account Settings,左边选择SSH Keys,Add SSH Key,title随便填,粘贴key
验证是否成功:
ssh -T git@github.com
4、在github上创建一个新的repository
5、初始化本地Repository
mkdir ~/YourRepositoryName
cd ~/YourRepositoryName
git init
touch README
git add README
git commit -m 'first commit'
6、将本地Repository连接到远程github上对应的Repository
git remote add origin https://github.com/yourName/YourRepositoryName.git
git push origin master
若出现:
error: The requested URL returned error: 403 while accessing https://github.com/yourName/YourRepositoryName.git/info/refs
fatal: HTTP request failed
git remote set-url origin ssh://git@github.com/yourName/YourRepositoryName.git
git push origin master
1、在github上注册一个帐户,并登录
2、安装和配置git
sudo apt-get install git-core
git config --global user.name "Your Name Here"
git config --global user.email "your_email@example.com" //这里的email地址应该与你登录github的email账户地址保持一致
git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=3600'
3、Generating SSH Keys (https://help.github.com/articles/generating-ssh-keys)
ssh-keygen -t rsa -C "your_email@example.com" //这里的email地址应该与你登录github的email账户地址保持一致
ssh-add ~/.ssh/id_rsa
成功的话会在~/下生成.ssh文件夹,进去,打开id_rsa.pub,复制里面的 key。
回到github,进入Account Settings,左边选择SSH Keys,Add SSH Key,title随便填,粘贴key
验证是否成功:
ssh -T git@github.com
4、在github上创建一个新的repository
5、初始化本地Repository
mkdir ~/YourRepositoryName
cd ~/YourRepositoryName
git init
touch README
git add README
git commit -m 'first commit'
6、将本地Repository连接到远程github上对应的Repository
git remote add origin https://github.com/yourName/YourRepositoryName.git
git push origin master
若出现:
error: The requested URL returned error: 403 while accessing https://github.com/yourName/YourRepositoryName.git/info/refs
fatal: HTTP request failed
git remote set-url origin ssh://git@github.com/yourName/YourRepositoryName.git
git push origin master