使用Git的基本操作

认识Git也蛮久了,至今也只能算是认识而已吧
基本用法如下:
1.cd 指定的目录 进入指定的目录
注意:windows下的目录是D:\Git,但使用Git需要写成/d/Git

2.git init 初始化本地仓库

3.创建本地SSH Key
$ ssh-keygen -t rsa -C "邮件地址"
你需要把邮件地址换成你自己的邮件地址,然后一路回车,使用默认值即可,由于这个Key也不是用于军事目的,所以也无需设置密码。
如果设置的话,每次push都要输入密码。
具体的可以看:
廖雪峰的git教程中 添加远程库:
https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013752340242354807e192f02a44359908df8a5643103a000
CODING的SSH 公钥设置:
https://coding.net/help/doc/git/ssh-key.html

4.如果你想要commit的话,你需要 Please tell me who you are.,这个时候你只要执行下面两条命令就可以了
$ git config --global user.email "[email protected]"
$ git config --global user.name "Your Name"
是不是很简单!

5.然后你可以使用git status 查看当前仓库commit的情况,并可以使用git commit -m "commit的内容" 命令进行commit

6.commit后想要push?

$ git remote add origin [email protected]:hsocode/xiaoxuan.git
注意:[email protected]:hsocode/xiaoxuan.git 改为你的SSH路径

7.好了,现在你可以进行push了
git push -u origin master
这个时候又有问题了:

Warning: Permanently added the RSA host key for IP address '123.59.85.117' to the list of known hosts.
To git.coding.net:hsocode/xiaoxuan.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '[email protected]:hsocode/xiaoxuan.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

客官请看:https://blog.csdn.net/ken1583096683/article/details/80754369

到这里就是最最最基本的git操作,你学会了吗

猜你喜欢

转载自blog.csdn.net/ken1583096683/article/details/80945764