Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【git】与gitgub之间的联系方式 #3

Open
Kelichao opened this issue Jan 2, 2017 · 0 comments
Open

【git】与gitgub之间的联系方式 #3

Kelichao opened this issue Jan 2, 2017 · 0 comments
Labels

Comments

@Kelichao
Copy link
Owner

Kelichao commented Jan 2, 2017

如何用git在github提交文件

一、生成ssh秘钥

$ ls -al ~/.ssh #检查本地的ssh
$ ssh-keygen -t rsa -C "[email protected]" # 创建新的ssh秘钥命令

会给出秘钥存放位置

default

文件目录

default

二、将新生成的key添加到ssh-agent中

eval "$(ssh-agent -s)"
# Agent pid 59566
ssh-add ~/.ssh/id_rsa

default

三、将ssh key添加到GitHub中

  • 用自己喜欢的文本编辑器打开id_rsa.pub文件,里面的信息即为SSH key,将这些信息复制到GitHub的Add SSH key页面即可

image

image

四、将库克隆到本地

image

将我创建的远端库克隆到本地的命令

git clone [email protected]:Kelichao/gittest.git

我的电脑上生成了目标目录

image

五、连接远端仓库

git remote add origin [email protected]:Kelichao/gittest.git #与我想要上传的github仓库链接

如果出现了fatal: remote origin already exists.则需要切断之前的git链接

git remote rm origin #先删除远程 Git 仓库 连接
git remote add origin [email protected]:Kelichao/gittest.git #上传代码

六、提交本地代码到远端库

提交修改好的文件到远端仓库

git add bbb.txt# 添加文件到缓存
git commit -m "添加一个新文件"
git push origin master #提交到远端绑定好的代码仓库

image

提交成功
image

@Kelichao Kelichao added the 总结 label Jan 2, 2017
@Kelichao Kelichao added 笔记 and removed 总结 labels Feb 26, 2017
@Kelichao Kelichao changed the title github与git联系方式 【git】与gitgub之间的联系方式 Feb 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant