挂链接!讲的太好了
【40 分钟学会 Git | 日常开发全程大放送&搭配Github-哔哩哔哩】 https://b23.tv/ITDifdD
做了一个简单的小的总结,偶尔也遇到了一点小问题。
1.从github上下载项目
git clone https://github.com/WriteCodee/gogocode-test.git
这与Download ZIP的区别是,使用git clone下载下来的是一个仓库,会有一个.git,而不是一个平平无奇的文件夹。通过git init可以将文件夹初始化为仓库。
2.将修改的文件上传到暂存区
git add 文件名
如果上传所有文件到暂存区
git add -A
撤回更改
git checkout 文件名
撤回提交
git reset HEAR^1(数字是倒数第几次提交)
3.提交
git commit -m “修改了xxx” // “ ”中的内容是提交的备注信息。
但是需要
首先
需要添加自己GitHub邮箱和用户名,即知道你是谁。
git config --global user.email "xxx@qq.com"
git config --global user.name "Username"
git commit -m "xxx" // 提交
查看提交历史
git log --stat
4.分支
以当前节点创建分支
git checkout -b <分支名字>
1完成之后会发现2
列举所有的分支
git branch
单纯的切换到某个分支
git checkout <分支名字>
删掉特定的分支
git branch -D <分支名字>
合并分支
git merge <分支名字>
5.Git与GitHub远程仓库
先创建一个仓库
github页面右上角+New repository :gogocode-test
然后create。
因为是已有的仓库,所以选用第二个:从命令行推送到现有的仓库
首先
git remote add origin https://github.com/xxx/gogocode-test1.git
报错了:error: remote origin already exists.
远程源已经存在
解决方案:
1.查看远程库的信息:git remote -v
2.删除现有的远程仓库:git remote rm origin
3.建立新的远程仓库地址:git remote add origin https://github.com/xxx/gogocode-test1.git(远程仓库地址:自己修改)
其次
git branch -M main
最后
git push -u origin main
但是报错了:
fatal: unable to access 'https://github.com/xxx/gogocode-test.git/': Failed to connect to github.com port 443 after 21069 ms: Couldn't connect to server
百度:这是由于本机系统代理端口和git端口不一致导致的(https://blog.csdn.net/m0_64007201/article/details/129628363)
解决办法:
设置->代理:
然后在终端执行:
git config --global http.proxy http://127.0.0.1:10809
git config --global https.proxy http://127.0.0.1:10809
然后再:
git push -u origin main
会出来一个授权页面。
授权成功后刷新github页面,上传成功!
如果在github上修改,或者大家同理合作一起修改,然后第二天我想拉取最新的项目,就是大家更改之后的,那么git pull。