0
点赞
收藏
分享

微信扫一扫

Git 使用


git是一款免费的、开源的分布式版本控制系统,本文是关于git的使用,不断更新。

git常用命令

​git init​​​将目录变成git可以管理的仓库,这里会生成一个git文件夹,用来跟踪管理版本的。
​​​git add .​​​将所有文件添加到暂存区
​​​git commit -m 'first commit'​​​将文件提交到仓库
​​​git remote add origin 你的远程库地址​​​这里仅初次需要关联
​​​git pull --rebase origin master​​​获取远程库与本地库合并(拉pull)
​​​git push -u origin master​​​将本地库的内容推送到远程
​​​git status​​状态查询功能

Git 使用_git

git 分支

发现自己对git了解的还是太少了,重新开始git的学习。
分支在实际中有什么用呢?假设你准备开发一个新功能,但是需要两周才能完成,第一周你写了50%的代码,如果立刻提交,由于代码还没写完,不完整的代码库会导致别人不能干活了。如果等代码全部写完再一次提交,又存在丢失每天进度的巨大风险。

现在有了分支,就不用怕了。你创建了一个属于你自己的分支,别人看不到,还继续在原来的分支上正常工作,而你在自己的分支上干活,想提交就提交,直到开发完毕后,再一次性合并到原来的分支上,这样,既安全,又不影响别人工作。
​git分支的理解​​

修改git文件语言

git按照文件中比较多语言类型标识默认语言,项目中创建一个txt文件,命名为​​.gitattributes​​​内容为​​*.html linguist-language=python​​​,这样可以将文件中比较多的html文件标识为python。
​如何修改github项目中的语言设定​​

常见错误

错误1

当不小心commit的文件过大,push失败。
1.首先查看最近的提交

git log

2.依次撤销大文件后的commit

git reset commitid

3.删除大文件,备份到其他地方

git rm -r --cached /Users/xxx

4.重新提交

git commit --amend -CHEAD

执行完之后,这个大文件就会从commit记录里移除,就可以commit push到github上了
​处理GitHub不允许上传大于100M文件问题​​git push 推送大文件失败的处理办法

错误2

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解决办法:先pull 再push
​​​git pull --rebase origin master​​​获取远程库与本地库合并(拉pull)
​​​git push -u origin master​​​将本地库的内容推送到远程
​Git error​​

未完待续…
​如何用命令将本地项目上传到git​​Git使用教程


举报

相关推荐

【git】git使用

Git使用

git 使用

GIT使用

git使用

【GIT】Git 使用必会命令

0 条评论