赞
踩
ssh-keygen -t rsa -C “username” (注:username为你git上的用户名)
如果执行成功。返回
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/username/.ssh/id_rsa):
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/username/.ssh/id_rsa):
首先,说明一下,这里的username是你电脑上的用户名
然后,在这里就是设置存储地址了.我们直接按回车,会出现一下两种情况的一种:
(1)
如果正常运行的话,会出现
Enter passphrase (empty for no passphrase):
然后我们直接回车
上面的任意两种情况之后,会出现
Enter same passphrase again:
再次回车,这时候你会看见:
Your identification has been saved in /Users/username/.ssh/id_rsa.
Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
The key fingerprint is:
58:42:8b:58:ad:4b:b5:b9:6d:79:bf:8c:f9:e2:2b:ed
username
The key’s randomart image is:
这说明SSH key就已经生成了。文件目录就是:/Users/username/.ssh/id_rsa.pub.
我们执行cat命令查看文件的内容:
cat /User/username/.ssh/id_rsa.pub
这时候会看见:
ssh-rsa AAAAB3NzaC1yc2。。。。。。。。。
后面的内容我省略了
(说明:ssh-rsa 后面的内容这就是你的SSH keys)
把显示出来的SSH
keys直接添加到github账户设置里边的SSH keys
最后再执行git clone命令就可以了
只需要命令就可以把本地的项目上传到自己的github上。。步骤如下:
1.登陆自己的github账号,如下图所示:
2.点击new repository进行创建一个新的仓库,用来存放自己的项目;
3.也是最重要的部分,用命令将项目上传;
1.cd 到上传项目的根目录下,然后初始化本地仓库,git init
2.添加当前工作目录文件到index,添加管理,
git add *(记得有个点哦,并且和add之间有空格)
3.查看一下当前目录所有没有被git管理的文件以及被git管理并且被修改但是还没有提交的文件,
git status (若出现了很多红色文件,那么就需要再次进行2的步骤,git add .直到没有问题。)
4.提交文件,把本地仓库暂存区的文件提交到本地仓库。
git config --global user.name ""
git config --global user.email ""
git commit -m “message” 其中message就是你提交文件时候的备注。以便知道本次提交是什么作用……
5.关联远程仓库,其中origin后跟的是,远程仓库的别名。
git remote add origin https://github.com/bendan321/nihao.git
6.push文件。
git push -u origin master。
OK,这样的话,就完成了将本地项目传到github上了。
配置忽略的文件,不提交:
在gitbush中:
touch .gitignore
打开该文件,将不需要提交的文件以相对路径的方式添加到该配置文件中
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。