终端使用Git
brew install git
安装Git
git --version
git version 2.30.1 (Apple Git-130)
which git
/usr/bin/git
查看git的安装目录
git clone https://github.com/xxx/myRepository.git
copy到github上code下的URL下载项目到当前文件夹
VSCode终端使用Git
git add -A
将所有的文件提交到暂存区
git commit -m "commit备注信息"
提交到仓库
git log --stat
查看提交的信息
git checkout 文件名
在未提交的情况下进行回滚
git reset HEAD^
在已提交的情况下进行回滚,会回到上一步修改的界面,然后在左上角点撤销
git checkout -b 分支名
创建并切换分支,在此分支进行代码修改并提交不影响主分支及其他分支
git checkout main/master
切换到主分支
git merge a
在主分支下合并a分支
git merge --abort
放弃合并,如果发现主分支已经被修改可以选择处理后merge,也可以先放弃,请求协助
git branch
显示所有分支
git branch -D a
删除a分支
git push
推送到远程仓库
fatal: unable to access 'https://github.com/xxx/myRepository.git/': HTTP/2 stream 1 was not closed cleanly before end of the underlying stream
对于上述报错的解决方案(将默认通信协议修改为 http/1.1)
git config --global http.version HTTP/1.1
git pull
拉取远程仓库的代码
GitHub找开源项目
1、GitHub的trending模块
https://github.com/trending/https://github.com/trending/2、推荐项目的媒体
https://github.com/521xueweihan/HelloGitHubhttps://github.com/521xueweihan/HelloGitHub3、科技爱好者周刊
https://github.com/ruanyf/weeklyhttps://github.com/ruanyf/weekly
GitHub搜索小技巧:
1、百科大全
awesome +具体技术的名字
2、找例子
xxx sample
3、找空项目架子
xxx starter / xxx boilerplate
4、找教程
xxx tutorial