Git命令

Linux git下载命令 sudo apt-get install git

#Git官网:https://git-scm.com/
##git常用命令合集
git(gitbash)
##1下载命令(克隆):git clone 网络地址 (本地路径可指定文件名)
git clone --recursive 用于循环克隆git子项目
##选择ssh链接
2curl命令:curl http://www.baidu.com
3git配置用户名:
git config --global user.name “name”
3.1查看命令:git config --global user.name
4git配置邮箱:
git config --global user.email “1*****@qq.com”
4.1查看命令:git config --global user.email
5(创建本地仓库)选择进入目录作为仓库
输入命令:git init (初始化目录,作为本地仓库)

工作区(代码) 暂存区 本地仓库 gitee/github
–>> git add git commit git push --set-upstream origin master:master git push或者git push origin master

文件创建:touch str.txt
##(重要)状态查询:git status
工作状态:
文件未跟踪状态:untracked
##第一步:推荐使用:git add .
"."通配符表示全部文件add
使用git add str.txt

##第二步暂存区提交到仓库: git commit -m “注释”
查看仓库提交历史
git -log
##提交过滤文件
touch .gitignore
vim .gitignore
在里面编辑 *.a 表示过滤.a拓展名的提交
##分支查看:git branch
##创建分支:git branch dev
查看分支:git log

wangh@DESKTOP-MDDSKT8 MINGW64 ~/githome (master)
$ git log
commit 0d6b6f4e376747a5ab69930d0dcffa3ace6e6279 (HEAD -> master, dev)
Author: wanghuafeng <1250550692@qq.com>
Date:   Wed Jan 11 19:25:18 2023 +0800

    SKT,T1

注:dev表示分支名
##切换分支:git checkout dev
##合并分支:git merge dev
##删除分支:git branch -d dev
##强行删除分支:git branch -D dev
#上码云
##获取ssh公钥

wangh@DESKTOP-MDDSKT8 MINGW64 ~
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/wangh/.ssh/id_rsa):
Created directory '/c/Users/wangh/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/wangh/.ssh/id_rsa
Your public key has been saved in /c/Users/wangh/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:OqSRTBtmFelt49WGZF5dBnHlCoSfvokh/hb/fwdcCrg wangh@DESKTOP-MDDSKT8
The key's randomart image is:
+---[RSA 3072]----+
|      oo   ...o+*|
|     ..   +.. .+ |
|    =. . + *..  .|
|   = +. + = *. ..|
|    = .oSo + o.o |
|     + .o E . +  |
|    . o. . = o . |
|       .. o +   o|
|         o.  ...+|
+----[SHA256]-----+

wangh@DESKTOP-MDDSKT8 MINGW64 ~
$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDCB8SgXEuFq+0jSsRe/8B0GJjb4UU4rEVP0qD8zCI0HtRLxAYg1qgIADqXifHzxtW68Bix82ITcqKuAi8aDVwXtkV/n5QWURa7VGyOIwAk+2ib9BuehI9qul0eayb8SgcnFGYayTf4gaMuvTX/lZMAgoXoMUqUZSyCodGpAzhvolE/lbns0Tce2lhxEKmaucbmurj5+7Yd6xvAOIYT3d1J5vnqBO+l7EXEdz0L5GDrpHbEkLrgqgN5GkcMZzWL1zC035GrNzvYfccFZbQp6bXD8eP+PXyaDM/XTdvy/8T9KKO/9/a9lmKo/VO1M+MLbs5ynSXNu+ERkomhuvvCxOjcrwBUZTFWZ36Kn4qkv7KO8grGzakW692/cVcu4Q9YMQf3mgo3l5bkfAvSau6XZYJpvGwXp60DG7Zm2W6mFoCdZA8Q5TU34OTvwWSQsLPx/cc4gBv3GsrJ3rD9rec/kjnJQKo4mWBQ5NbWUX//h0BG/ulYIMF7PYiadN1znrl/cYM= wangh@DESKTOP-MDDSKT8

wangh@DESKTOP-MDDSKT8 MINGW64 ~

输入:ssh-keygen -t rsa (一路回车)
查询密钥:cat ~/.ssh/id_rsa.pub
打开码云ssh公钥输入密钥
##完成后验证连接:ssh -T [email protected]

wangh@DESKTOP-MDDSKT8 MINGW64 ~
$ ssh -T git@gitee.com
The authenticity of host 'gitee.com (212.64.63.190)' can't be established.
ED25519 key fingerprint is SHA256:+ULzij2u99B9eWYFTw1Q4ErYG/aepHLbu96PAUCoV88.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?yes


注意:并且输入yes回车
##绑定仓库(必须在本地仓库目录下添加)

wangh@DESKTOP-MDDSKT8 MINGW64 ~/githome (master)
$ git remote add origin git@gitee.com:whf1993/ESP32.git

wangh@DESKTOP-MDDSKT8 MINGW64 ~/githome (master)
$ git remote
origin

wangh@DESKTOP-MDDSKT8 MINGW64 ~/githome (master)

git remote add origin [email protected]:whf1993/ESP32.git
remote:表示远端仓库
origin:表示远程仓库名
仓库的地址:[email protected]:whf1993/ESP32.git
查看仓库:git remote
##第一种方式本地推送代码上云
git push origin master
##第二种方式关联本地和云端仓库(推荐使用)
关联:git push --set-upstream origin master:master
推送:git push
查询绑定状态:git branch -vv

你可能感兴趣的:(Git,git)