git 备忘

mac2026-06-22  0

1下载安装git 2连接github -$ ssh-keygen -t rsa -C “******@qq.com” -(/c/Users/liimou/.ssh/id_rsa) -在github上配置SSH

//##git user.username “Joe******” //##git user.emaile “******@qq.com” git config --global user.name “John Doe” git config --global user.email johndoe@example.com ##初始化本地git仓库 git init

##过滤文件 touch .gitignore vim .gitignore 退出vim:按Esc,推出编辑模式,然后按shift+;再输入q!(不保存)或者wq!(保存)

##添加所有文件 git add .

##提交文件 git commit -m “备注”

##查看状态 git status

##回退到上一步 git reset --hard HEAD^

##回退到 某个版本 git reset --hard b6a5c65

#查看历史版本 git reflog

##查看分支 git branch

##添加分支 git checkout -b branch_01 ##切换分支 git checkout master ##合并分支 git merge baranch_01 ##更新本地 git pull #加上后面这个选项允许不相关历史提交 git pull origin master --allow-unrelated-histories

##下载项目 git clone https://github.com/Microsoft/MixedRealityToolkit-Unity.git https://github.com/JoeManba/VR-LiuWuDianVR

############## 新建代码仓库后: 1、git init 2 、git add README.md 3、git commit -m “first commit” 4、git remote add origin git@github.com:JoeManba/MyRepository.git 5、git push -u origin master

################ 如果远程仓库为为空仓库, 那么需要在push前进行 如下命令: git pull origin master --allow-unrelated-histories 注意: 这里如果不加–allow-unrelated-histories, 会报错: fatal: refusing to merge unrelated histories

################ 创建和管理tag代码: 打标签:git tag tag名称 查看标签:git tag 提交标签:git push --tags

最新回复(0)