继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

git

qq_心存一人_2
关注TA
已关注
手记 3
粉丝 0
获赞 5

GIT生成SSH密钥:1.https://www.imooc.com/article/72092?block_id=tuijian_wz
2.https://www.jianshu.com/p/103735801a2e

GIT更新代码
git branch 查看当前分支
git pull 更新代码到本地

GIT修改文件、然后提交11111111: git status 查看状态
git add .  将修改的文件提交到缓存区
git commit - m "xxxx" 将缓存区代码提交到版本库
git push origin master 将版本库提交到远程仓库

GIT增加文件、然后提交:
git status 查看状态
git add .  将修改的文件提交到缓存区
git commit - m "xxxx" 将缓存区代码提交到版本库
git push origin master 将版本库提交到远程仓库

GIT忽略文件/文件夹:https://blog.csdn.net/weixin_43507521/article/details/86529642

GIT增加文件、修改部分文件、然后提交
git status 查看状态
git add .  将修改的文件提交到缓存区
git commit - m "xxxx" 将缓存区代码提交到版本库
git push origin master 将版本库提交到远程仓库

假如你把本地的GIT仓库搞乱了,你可以GIT清除本地库的缓存: git rm -r --cached .
然后重新 git add .

GIT删除文件、修改部分文件、然后提交
git status 查看状态
git add .  将修改的文件提交到缓存区
git commit - m "xxxx" 将缓存区代码提交到版本库
git push origin master 将版本库提交到远程仓库

当我们需要删除暂存区或分支上的文件, 同时工作区也不需要这个文件了, 可以使用
git rm file_path
git commit -m 'delete somefile'
git push

当我们需要删除暂存区或分支上的文件, 但本地又需要使用, 只是不希望这个文件被版本控制, 可以使用
git rm --cached file_path
git commit -m 'delete remote somefile'
git push

--------------------------------以上为基础指令学习----------------------------------

--------------------------------以下为进阶指令学习----------------------------------

有时会出现退GIT远程仓库版本的需求:

首次尝试使用了
git log  查看版本信息
git reset --hard HEAD^^  回退本地工作区版本
git push -force origin master 强制push
https://www.liaoxuefeng.com/wiki/896043488029600/897013573512192在-force时报了一个错:you are not allowed to push code to protected branches on this project
该问题的起因是因为新建GIT仓库时,master分支默认是protected,不允许强制push
随后在gitLab上更改设置即可:https://blog.csdn.net/zzh920625/article/details/78087669

随后发现reset并不是推荐的回退方式,应该使用revert
缘由请见:https://www.cnblogs.com/aligege/p/10221174.html

this is a git study project


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP