GIT基本使用

1.新建代码库

git init

2. 绑定远程仓库的地址

git remote add origin https://github.com/xxxx/xxxx.git #添加远程仓库的地址   

git remote remove origin #删除远程仓库的地址 

3.配置

git config --global user.name "xxx"
git config --global user.email "xxxx@gmail.com"

4.远程同步

git pull origin master --allow-unrelated-histories   #将远程仓库的代码拉取到工作区  第一次提交以前务必要拉取下来
git push origin master #将代码提交到远程仓库  

5.增加删除操作

git add  文件  #将文件提交到暂存区  
git commit -m '备注信息' #将暂存区的文件 提交到本地仓库  
git commit -a #上次提交发生变化的部分 提交上去  

6.设置不需要密码上传

ssh-keygen -t rsa -b 4096 -C "tongku@163.com"  #生成密钥对  
-t 密钥类型  
-b 块大小  
-C 指定用户名 不指定就是你的主机名

$ ssh-keygen -t rsa -b 4096 -C "tongku@163.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/neyo/.ssh/id_rsa): /c/Users/zjy/.ssh/id_git_rsa #指定密钥对存放位置  为了不覆盖掉原来的密钥对 我们重新生成一个
Enter passphrase (empty for no passphrase): 回车
Enter same passphrase again: 回车 
Your identification has been saved in /c/Users/neyo/.ssh/id_git_rsa.
Your public key has been saved in /c/Users/neyo/.ssh/id_git_rsa.pub.
The key fingerprint is:
SHA256:NxAhKrDlkxATujGq0hzEQhgmdYRliysrAzHL+CKDewE tongku@163.com
The key's randomart image is:
+---[RSA 4096]----+
|XBo+= . o.       |
|*O.= o . .       |
|O O o   .        |
|EX +     .       |
|Boo     S o      |
|+*..     . .     |
|@ +.             |
|+=.              |
|..               |
+----[SHA256]-----+


cd /c/Users/zjy/.ssh/  

cat id_git_rsa.pub 

将密匙内容加入到github端的key中

 7.git产生新分支后拉取新分支及代码

git fetch

8.在任务分支拉取指定分支的代码

git pull origin 指定分支号

9.git stash

会将已经修改的代码暂存,stash pop可以释放出来,可以多次stash,stash时相当于堆栈的操作,依次stash pop可以将之前stash的内容逐次释放出来

 

posted @ 2020-07-29 21:29  zjyss  阅读(168)  评论(0编辑  收藏  举报