有一个文件被跟踪git,但现在该文件在.gitignore列表中.
但是,该文件在git status编辑后会一直显示.你怎么强迫git完全忘掉它?
我的.gitignore文件似乎被Git忽略了 - 该.gitignore文件可能已损坏吗?Git期望哪种文件格式,语言环境或文化?
我的.gitignore:
# This is a comment
debug.log
nbproject/
Run Code Online (Sandbox Code Playgroud)
输出来自git status:
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# debug.log
# nbproject/
nothing added to commit but untracked files present (use "git add" to track)
Run Code Online (Sandbox Code Playgroud)
我想,debug.log而nbproject/不是出现在未跟踪的文件列表中.
我应该从哪里开始寻找解决方法呢?
我需要在我的.gitignore文件中添加一些规则,但是,我在项目文件夹中找不到它.它不是由Xcode自动创建的吗?如果没有,什么命令允许我创建一个?
我的存储库中有一个现有的Visual Studio项目.我最近在我的项目下添加了一个.gitignore文件,我假设它告诉Git忽略文件中列出的文件.
我的问题是所有这些文件都已被跟踪,据我所知,Git不会忽略在将规则添加到此文件之前已被跟踪的文件以忽略它.
有人建议使用:git rm --cached并手动取消跟踪它们,但这将永远让我一个接一个地浏览它们.
我想删除存储库并重新创建它,但这次使用.gitignore文件,但必须有更好的方法来执行此操作.
无论我放入什么,.gitignore我都无法得到git忽略UserInterfaceState.xcuserstate下面的文件:
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .gitignore
modified: CalFoo.xcodeproj/project.xcworkspace/xcuserdata/wcochran.xcuserdatad/UserInterfaceState.xcuserstate
Run Code Online (Sandbox Code Playgroud)
我正在使用/编辑此帖子中.gitignore列出的文件.我尝试了一切以匹配模式,包括确切的路径名:无济于事.CalFoo.xcodeproj/project.xcworkspace/xcuserdata/wcochran.xcuserdatad/UserInterfaceState.xcuserstate
这个特殊问题源于使用Xcode创建初始git repo并且之后添加.gitignore来自此处的文件的工作流程.从这个问题中可以找到忽略git中先前跟踪文件的更一般的答案(我想我在搜索中从未找到过这个帖子,因为它在标题中没有"gitignore").
settings.cpython-36.pyc即使已将其添加到文件中,我的应用程序中的文件也不会被忽略.gitignore。
我的gitignore代码:
*.log
*.pot
*.pyc
.idea
LearnDjango/__pycache__/
venv/
/LearnDjango/settings.py
LearnDjango/__pycache__/settings.cpython-36.pyc
Run Code Online (Sandbox Code Playgroud)
LearnDjango/__pycache__/gitignore文件中的这一行会忽略其他.cpython-36.pyc文件,但不会settings.cpython-36.pyc
__pycache__文件夹视图,第一个和第三个文件被忽略,但第二个不被忽略
PS我是Django和git的新手。
我的存储库顶层文件夹中有一个.gitignore文件,其中包含以下代码:
# Compiled python modules.
*.pyc
# Backup gedit files.
/*~
# Setuptools distribution folder.
/dist/
# Python egg metadata, regenerated from source files by setuptools.
/*.egg-info
/*.egg
Run Code Online (Sandbox Code Playgroud)
当我尝试运行git add .命令时,.gitignore无效,因为添加了多个/ *〜。的输出git status如下:
new file: uvispace/tests/test_messenger.py
new file: uvispace/tests/test_messenger.py~
new file: uvispace/tests/test_robot.py~
new file: uvispace/uvirobot/__main__.py~
new file: uvispace/uvirobot/messenger.py~
new file: uvispace/uvirobot/move_base.py
Run Code Online (Sandbox Code Playgroud)
我见过几个非常类似的问题,像这一个,或这一个。他们的解决方案是删除先前添加的文件,然后按照以下说明再次添加整个存储库:
git rm -rf --cached .
git add *
Run Code Online (Sandbox Code Playgroud)
但是,我尝试过,没有区别。有人知道为什么会这样吗?
我已经在 Pycharm 中为我的团队项目设置了项目解释器。我已经从 Git 克隆了它。我们已在 .gitignore 中的 .idea 文件夹下列出了该文件。但每次我设置项目解释器时,Pycharm 都会将这些文件跟踪为更改的文件。这是我们的 gitignore
*.pyc
doc/.*
partner/.*
.settings/
doc
tests/test.py
tests/format_db.py
nohup.out
crawler/uber.py
.idea/*
.vscode/*
broadcast.log
last_commit.txt
Run Code Online (Sandbox Code Playgroud) 我在源树中有 Xamarin.iOS 项目 git 文件。问题是列出调试文件的 xamarin 未暂存文件。我试图忽略调试。文件使用 .gitignore 文件放置在 bin 和 obj 文件夹中。仍然列出调试文件。
这是我使用网站https://www.gitignore.io创建的 gitignore 文件内容
-------------------------
# Created by https://www.gitignore.io/api/macos,visualstudio,xamarinstudio
### macOS ###
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### XamarinStudio ###
bin/
obj/
*.userprefs …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用.gitignore来防止GitHub将更改提交到我的项目中的文件(文件包含API密钥和访问Web服务的秘密).
它不起作用 - 我在GitHub上的项目不断得到更改,即使我已经确认该文件位于项目的.gitignore文件中.
如果我使用git update-index --assume-unchanged,有问题的文件将完全从repo中删除.我想要那里的文件; 我只是不希望我的更改同步.
我错过了什么?
.gitignore是:
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
#*.resw
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest …Run Code Online (Sandbox Code Playgroud)