Git及GitHub的使用

终端使用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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值