git study note
2019-04-14 本文已影响0人
宣雄民
-
What's the backup after mis-pulled remote data to your local data
a. git reflog
b. git reset --hard@{x}
c. you done
d. git push -f origin master # force push to remote repository -
Difference between pull and fetch
image.png
https://www.cnblogs.com/runnerjack/p/9342362.html
- git fetch gets the newest data and let user decide when and how to merge
- git pull = git fetch + git merge which may cause potential conflicts and the manual operation will be called.
- git branches management
-
Types of branches
-
master
main repository - keep updated -
dev
developing repository - currently working on it which also needs to be updated -
bug
issues or problems of the application that are need to be fixed, updating is not necessarily -
feature
future work which are either keeping locally or push to the remote repository.
-
master
-
How to create and maintain dev branch
image.png
image.png
image.png
image.png
image.png
Work flow:- Create a new pointer points to
dev
and theHEAD
pointer now points to it. - if the
dev
branch is done, we need to mergedev
tomaster
by simply turningmaster
todev
and then we can delete thedev
pointer andmaster
becomes the only branch that's left.
"直白说就是建立一个新的分支,此时HEAD指针指向新的分支,需要注意的是它的底层原理为不管是master还是其它分支,它们都是指针被保存在
.git文件夹中并且指向用户对工作区中内容的修改进度
,所以当合并其他分支和主分支时,也就是简单地将主分支指向这些进度的指示指向了我们觉得OK的新进度指针。" - Create a new pointer points to
-
How to link local dev with remote repository
Quite simple!
git checkout dev git push origin dev
Now you can work on your dev branch and push the newest data to remote repository
git ignore and git add commit retreat
#设置哪些文件该过滤
node_modules/ #表示过滤这个文件夹
*.zip #过滤zip后缀文件
demo.html #过滤该文件
#反向操作,设置哪些文件不该过滤
!src/ 跟踪该文件夹
!*.js 跟踪java源文件
!index.html 跟踪该文件
git rm -r --cached . //依照.gitignore文件删除本地仓库的多余文件
git add . //重新添加
git commit -m 'update .gitignore' //重新commit
git lfs install //安装lfs
git lfs track "*.pdf" //使用lfs跟踪需要管理的大文件,也可以直接编辑.gitattributes文件
//然后走常规流程
git add yourLargeFile.pdf
git commit -m "Add Large file"
git push -u origin master
# [https://git-lfs.github.com/](https://git-lfs.github.com/)