git study note

  1. 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

  2. Difference between pull and fetch
    https://www.cnblogs.com/runnerjack/p/9342362.html

    image.png

  • 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.
  1. 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.
  • How to create and maintain dev branch

    image.png

    image.png

    image.png

    image.png

    image.png

    Work flow:

    1. Create a new pointer points to dev and the HEAD pointer now points to it.
    2. if the dev branch is done, we need to merge dev to master by simply turning master to dev and then we can delete the dev pointer and master becomes the only branch that's left.

    "直白说就是建立一个新的分支,此时HEAD指针指向新的分支,需要注意的是它的底层原理为不管是master还是其它分支,它们都是指针被保存在.git文件夹中并且指向用户对工作区中内容的修改进度,所以当合并其他分支和主分支时,也就是简单地将主分支指向这些进度的指示指向了我们觉得OK的新进度指针。"

  • 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/)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • origin websiteComparing WorkflowsCentralized Workflow Fea...
    伍帆阅读 566评论 0 0
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,694评论 0 10
  • 1. GIT命令 git init在本地新建一个repo,进入一个项目目录,执行git init,会初始化一个re...
    江边一蓑烟阅读 887评论 0 0
  • The Inner Game of Tennis W Timothy Gallwey Jonathan Cape ...
    网事_79a3阅读 12,781评论 3 20
  • ……拿了硕士学位,去了丹麦英国出了个差,回国和我哥们儿喝酒吃肉,告别了我大斯德哥尔摩,投了上百份简历收了一半儿拒信...
    妙MeowMooo阅读 194评论 7 5

友情链接更多精彩内容