初次使用github问题集锦
2012-08-03 23:17 tetang1230 阅读(301) 评论(0) 收藏 举报- 注册https://github.com/
- create repository.
- 在linux下clone一个你刚刚建repository
- 例如:git clone https://github.com/tetang1230/linux.git
- 建立一个测试文件README,然后git push
-
然后出现以下错误:
Agent admitted failure to sign using the key. Permission denied
(publickey)
fatal: The remote end hung up unexpectedly -
查看github的官方文档
#1. Check for SSH keys.
$ cd ~/.ssh
#2. Backup and remove existing SSH keys.
$ lsLists all the subdirectories in the current directory
$ mkdir key_backupmakes a subdirectory called "key_backup" in the
current directory
$ cp id_rsa* key_backupCopies the contents of the id_rsa directory
into key_backup
$ rm id_rsa*
#3. Generate a new SSH key.
$ ssh-keygen -t rsa -C "your_email@youremail.com"
#4. Add your SSH key to GitHub.(点击你的github account setting,找到SSH KEYS选项,把刚刚生成的key添加进去,我是在/root/.ssh/id_rsa.pub文件中找到,以'ssh-rsa'开头)ssh-add ~/.ssh/id_rsa
#5. Test everything out.
$ ssh -T git@github.com(如果出现Could not open a connection to your authentication agent,就执行ssh-agent bash --login -i 命令)
大概意思就是你现在本地建立自己的SSH密码对,然后将公钥上传到github就行
了。 - 继续git push,如果出现 [branch "master"]
remote = origin merge = refs/heads/master see git-config(1) for details 这等于告诉git2件事:
1. 当你处于master branch, 默认的remote就是origin。
2. 当你在master branch上使用git pull时,没有指定remote和branch,那么git就会采用默认的remote(也就是origin)来merge在master branch上所有的改变
如果不想或者不会编辑config文件的话,可以在bush上输入如下命令行:
- $ git config branch.master.remote origin
- $ git config branch.master.merge refs/heads/master
- 继续Push,OK了现在!
git push -u git@github.com:tetang1230/test.git master
Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/tetang1230/vim.git
git push -u origin master
Push an existing repository from the command line
git remote add origin https://github.com/tetang1230/vim.git
git push -u origin master