• 更新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

  • 相关阅读:
    C# 编码约定
    SQL 合并多列为一行字符串
    Flex 粒子效果
    安装flashplayer 提示 "您尝试安装的 Adobe Flash Player" 版本不是最新版本. 请访问 Player 下载中心 获取最新、最安全版本"的解决方法
    Flex Builder 好用的插件
    【默认】博客正式开通
    Vulkanished2021重要内容简介
    论文读书笔记8
    论文读书笔记5
    论文读书笔记2
  • 原文地址:https://www.cnblogs.com/rsapaper/p/12484881.html
Copyright © 2020-2023  润新知