zoukankan      html  css  js  c++  java
  • 更新gitignore后如何使其生效

    Files already tracked by Git are not affected; 

    Git - gitignore Documentation https://git-scm.com/docs/gitignore

    gitignore - Specifies intentionally untracked files to ignore

    NOTES

    The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked.

    To stop tracking a file that is currently tracked, use git rm --cached.

     
     

    更新gitignore后如何使其生效_Falcon2000的专栏-CSDN博客 https://blog.csdn.net/Falcon2000/article/details/82830639

    我们应该先把本地的缓存删除,然后再进行push,操作步骤如下

    1.  
      git rm -r --cached . // 删除本地缓存
    2.  
      git add . // 添加要提交的文件
    3.  

     【实践出真知】

    注意,上述会导致提交后的diff变动为与clone本地文件时的commentId 做比较

    例如

    git clone -b test url

    git log commentId01 

    本地先后提交了02,03,04,05;

    在提交06前执行了 git rm -r --cached .  会导致 push 06后,diff是相对01的,而非相对05的;虽然提交的内容确实是06下的内容。

    [git] 如何解决修改了.gitignore却不生效 - 简书 https://www.jianshu.com/p/6d06583c536c

    1、问题描述:

    在使用git时,想忽略某些不想提交的文件,可以在项目中修改.gitignore文件,如果没有这个文件,可以手动建一个。但是常常发现修改后,点击提交,发现没有生效。

    2、原因分析:

    因为.gitignore只能忽略那些原来没有被track过的文件,如果某些文件已经被纳入了版本管理中,则修改.gitignore是无效的。解决方法就是先把本地缓存删除(改变成未track状态),然后再提交。

    3、解决办法:

    在所在的库逐次执行下面命令:

    git rm --cached --force "file-to-path"
    git rm --cached --force "file2-to-path"
    ...

    git ignore 语法

    注意*的误用

    # The slash / is used as the directory separator. Separators may occur at the beginning, middle or end of the .gitignore search pattern.

    # If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself. Otherwise the pattern may also match at any level below the .gitignore level.

    # An asterisk "*" matches anything except a slash. The character "?" matches any one character except "/". The range notation, e.g. [a-zA-Z], can be used to match one of the characters in a range. See fnmatch(3) and the FNM_PATHNAME flag for a more detailed description.
    # A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
    /src/app/settings_conf/local.py

    https://git-scm.com/docs/gitignore

  • 相关阅读:
    学习good taste代码
    linux程序运行浅析
    菜鸟安装 CocoaPods
    菜鸟安装 CocoaPods
    CocoaPods一个Objective-C第三方库的管理利器
    CocoaPods一个Objective-C第三方库的管理利器
    intrinsicContentSize和Content Hugging Priority
    intrinsicContentSize和Content Hugging Priority
    UITableViewCell delete button 上有其它覆盖层
    UITableViewCell delete button 上有其它覆盖层
  • 原文地址:https://www.cnblogs.com/rsapaper/p/12484881.html
Copyright © 2011-2022 走看看