美文网首页
git study note

git study note

作者: 宣雄民 | 来源:发表于2019-04-14 22:57 被阅读0次
    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/)
    
    

    相关文章

      网友评论

          本文标题:git study note

          本文链接:https://www.haomeiwen.com/subject/bvvewqtx.html