Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 如何推送文件并在之后忽略它_Git_Github_Gitlab - Fatal编程技术网

Git 如何推送文件并在之后忽略它

Git 如何推送文件并在之后忽略它,git,github,gitlab,Git,Github,Gitlab,我创建了一个新的回购协议,并希望推进我的项目。但是我有一些像config.js这样的文件。我想推一次config.js。我已经推送了它,将config.js添加到.gitignore,但是更改了config.js的提交。我怎么能推一次呢 .gitignore: node_modules/ DB/ sessions/ git状态 git status On branch master Changes not staged for commit: (use "git add/rm <fi

我创建了一个新的回购协议,并希望推进我的项目。但是我有一些像config.js这样的文件。我想推一次config.js。我已经推送了它,将config.js添加到.gitignore,但是更改了config.js的提交。我怎么能推一次呢

.gitignore:

node_modules/
DB/
sessions/
git状态

git status
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   .gitignore
        modified:   DB/DB.js
        modified:   DB/pg.js
        modified:   app.js
        modified:   policies.js
        modified:   rights.js
        deleted:    sessions/ed83156281f80feb08ede1b087d0a91bd34e78eca8f210d4c0a0b8b8c1b50390.ses

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        rightsDict.js
git状态
论分行行长
未为提交而暂存的更改:
(使用“git add/rm…”更新将提交的内容)
(使用“git签出--…”放弃工作目录中的更改)
修改:.gitignore
修改:DB/DB.js
修改:DB/pg.js
修改:app.js
修改:policies.js
修改:rights.js
删除:sessions/ED8315628F80FEB08EDE1B087D0A91BD34E78ECA8F210D4C0A0B8B8C1B50390.ses
未跟踪的文件:
(使用“git add…”包含在将提交的内容中)
rightsDict.js

为什么我的文件夹数据库在列表中?

在清理存储库之前,您应该进行两项重要的准备工作:

  • 确保.gitignore文件是最新的,并且包含所有 纠正您想要忽略的模式

  • 提交或隐藏任何未完成的本地更改。你的 继续之前,工作副本应该是干净的

    $ git rm -r --cached .                                                    
    $ git add .
    $ git commit -m "Clean up ignored files"
    

在清理存储库之前,您应该进行两项重要的准备工作:

  • 确保.gitignore文件是最新的,并且包含所有 纠正您想要忽略的模式

  • 提交或隐藏任何未完成的本地更改。你的 继续之前,工作副本应该是干净的

    $ git rm -r --cached .                                                    
    $ git add .
    $ git commit -m "Clean up ignored files"
    

如果您在未老化的文件中看到config.js,准备提交,那么您已经错误地配置了.gitignoreupdated(添加包含文件),看起来一切正常。你有其他人吗?在其他人的道路上,谁凌驾于谁的规则之上?您确定您的.gitignore与DB文件夹位于同一目录级别吗(看起来是,但我再次询问)。你试过在DB(DB/*)后面加*吗?ls-a
。git.gitignore DB
状态
列表中有
DB
的原因是您(很可能)在某个时候暂存了该目录,然后将其添加到
gitignore
中。您希望git停止跟踪您的
DB
文件夹吗?如果要推送一次文件,然后停止git再次跟踪它,则需要执行以下操作:
git-rm--cached
git-rm-r--cached
用于文件夹。检查您是否在未老化的文件中看到config.js,准备提交,因此您已经错误地配置了.gitignoreupdated(添加包含文件),看起来一切正常。你有其他人吗?在其他人的道路上,谁凌驾于谁的规则之上?您确定您的.gitignore与DB文件夹位于同一目录级别吗(看起来是,但我再次询问)。你试过在DB(DB/*)后面加*吗?ls-a
。git.gitignore DB
状态
列表中有
DB
的原因是您(很可能)在某个时候暂存了该目录,然后将其添加到
gitignore
中。您希望git停止跟踪您的
DB
文件夹吗?如果要推送一次文件,然后停止git再次跟踪它,则需要执行以下操作:
git-rm--cached
git-rm-r--cached
用于文件夹。检查