1.添加用户名和email地址
命令:
git config --global user.name "xxx"
git config --global user.email "xxx@xxx.com"
2.添加本地仓库
在目标目录下右击鼠标选择Git Bash Here
或者 cd 查找目标文件夹
命令:cd f:(盘)
cd xxxxx(文件夹)
找到目标文件夹之后:
git init
3.add 添加文件
git add . ---------添加所有文件
git add 文件名 ---------------添加单个文件
4.commit 提交
add之后就可以提交了
git commit -m "提交备注"
备注不能为空
5.push 到远程仓库
命令:$ git push origin master
如果提示:
$ git push origin master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
则需要添加远程仓库和ssh秘钥
步骤:
如果没有远程仓库需要添加
命令:git rmote add origin git@github.com:ruoxuanFu/wms-2.git --------------origin后面的可以看github的ssh地址
ssh秘钥步骤:
1.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):
首先,说明一下,这里的username是你电脑上的用户名
2.然后,在这里就是设置存储地址了.我们直接按回车,会出现一下两种情况的一种:
(1)如果正常运行的话,会出现
Enter passphrase (empty for no passphrase):
然后我们直接回车
(2)有的时候我们可能会出现
/Users/your username/.ssh/id_rsa already exists.
Overwrite (y/n)?
这说明你已经设置了存储地址,我们输入“y”覆盖
Overwrite (y/n)? y
3.回车
上面的任意两种情况之后,会出现
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:
+--[ RSA 2048]----+
| ... |
| o oo. |
| . .ooo. |
| o o+ |
| . ..oS. |
| . . + . |
| . o . |
| . o+. |
| +E++. |
+-----------------+
这说明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 命令就可以了
7万+

被折叠的 条评论
为什么被折叠?



