.gitignore是否在提交,推送或到达服务器时工作? [英] Does .gitignore work on commit, push, or upon reaching the server?
问题描述
.gitignore
来忽略所有 .class
文件。 当这些文件被保存在远程原点之外时...
-
我提交/添加我的文件在本地?当使用add / commit时,我的
git
是否会查找.gitignore
,并根据它的说法,从提交? -
我推我的提交?
git
git是否只推送未在.gitignore
中描述的文件? -
到达原点?是否持有git存储库的服务器根据它的
.gitignore
?
我在本地提交/添加我的文件?当使用添加/提交时,我的git是否会查找.gitignore,并根据它的说明从提交中删除内容?
git add
忽略文件和根据 .gitignore
。 git commit
不在意关于你的 .gitignore
。它使用已经由 git add
和 git rm
(以及其他 git
命令)添加到索引中。
git rm
是可用于删除文件并记录到要停止跟踪的索引中的命令它。如果您已经从工作树中删除了文件,您还可以使用 git add
将其删除记录到索引中。
我推我的提交? git git只推送那些没有在.gitignore中描述的文件吗?
git push
也不关心你的。 gitignore
,因为它不适用于文件。它向远程存储库发送已存在于本地存储库中的信息。如果您想忽略的文件已经存在,那么它也会到达远程存储库。
如果您在存储库中有文件,并且您不希望它们被跟踪你必须添加他们的名字(或匹配他们名字的通配符)到 .gitignore
和中,使用 git rm
将删除请求添加到索引中,以便在下一次提交时处理。
存储库中已存在的这些文件的版本和远程)不会被删除。你必须重写历史记录,但不建议许多人使用的存储库重写历史记录。
它到达了原点?
提交中的所有内容都会触及到您的gitignore远程存储库。但是当你的同事在他们的计算机上检查项目时,为了使 git
尊重 .gitignore
将 .gitignore
文件添加到存储库;并提交,并推送,当然,让 .gitignore
文件找到自己的系统。没有我的 .gitignore
和它的 gitignore
。必须将 .gitingore
文件添加到存储库(并在每次更改时进行提交),以便对每个人都有效。
Say I have a .gitignore
to ignore all .class
files.
Are these files kept out of the remote origin when...
I commit/add my files locally? Does my
git
look for a.gitignore
when add/commit is used, and based on what it says, removes things from the commit?I push my commits? Does
git
git only push files that aren't being described in the.gitignore
?It reaches the origin? Does the server that is holding the git repository keep out files based on it's
.gitignore
?
I commit/add my files locally? Does my git look for a .gitignore when add/commit is used, and based on what it says, removes things from the commit?
git add
ignores files and directories based on the rules expressed in .gitignore
. git commit
doesn't care about your .gitignore
. It creates a new commit in the local repository using the information already prepared by git add
and git rm
(and other git
commands) into the index.
git rm
is the command you can use to remove a file and record into the index you want to stop tracking it. If you have already removed the file from the working tree you can also use git add
to record its removal into the index.
I push my commits? Does git git only push files that aren't being described in the .gitignore?
git push
also doesn't care about your .gitignore
because it doesn't work with files. It sends to the remote repository information that already exists in the local repository. If the file you want to ignore is already there then it will go to the remote repository too
If you have files in the repository and you want them to not be tracked any more you have to add their names (or wildcards that match their names) into .gitignore
and use git rm
to add the removal request into the index, to be processed on the next commit.
The versions of those files that already exist in the repository (local and remote) are not deleted. You have to rewrite the history for that but rewriting history on a repository used by many persons is not recommended.
It reaches the origin? Does the server that is holding the git repository keep out files based on it's .gitignore?
Everything that's in the commits you push reach the remote repository. But in order for git
to respect .gitignore
when your co-workers check the project out on their computers, you have to add the .gitignore
file to the repository; and commit, and push, of course, to let the .gitignore
file find its way to their systems. There is no "my .gitignore
" and "its gitignore
". The .gitingore
file must be added to the repository (and committed every time it changes) in order to have effect for everybody.
这篇关于.gitignore是否在提交,推送或到达服务器时工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!