gitignore for git add
I want gitignore a file that is already committed and pushed to master;
Meaning, I want to ignore any change of that file.
But after I add the path in gitignore, it is still included in commit and pushed when I use
git add .
how do I ignore such file ?
git gitignore
add a comment |
I want gitignore a file that is already committed and pushed to master;
Meaning, I want to ignore any change of that file.
But after I add the path in gitignore, it is still included in commit and pushed when I use
git add .
how do I ignore such file ?
git gitignore
Possible duplicate of Ignore changes to a tracked file
– Paul Crovella
Nov 14 '18 at 4:55
1
Possible duplicate of Can I 'git commit' a file and ignore its content changes?
– 1615903
Nov 14 '18 at 7:20
add a comment |
I want gitignore a file that is already committed and pushed to master;
Meaning, I want to ignore any change of that file.
But after I add the path in gitignore, it is still included in commit and pushed when I use
git add .
how do I ignore such file ?
git gitignore
I want gitignore a file that is already committed and pushed to master;
Meaning, I want to ignore any change of that file.
But after I add the path in gitignore, it is still included in commit and pushed when I use
git add .
how do I ignore such file ?
git gitignore
git gitignore
asked Nov 14 '18 at 3:21
Isaac Sim
7410
7410
Possible duplicate of Ignore changes to a tracked file
– Paul Crovella
Nov 14 '18 at 4:55
1
Possible duplicate of Can I 'git commit' a file and ignore its content changes?
– 1615903
Nov 14 '18 at 7:20
add a comment |
Possible duplicate of Ignore changes to a tracked file
– Paul Crovella
Nov 14 '18 at 4:55
1
Possible duplicate of Can I 'git commit' a file and ignore its content changes?
– 1615903
Nov 14 '18 at 7:20
Possible duplicate of Ignore changes to a tracked file
– Paul Crovella
Nov 14 '18 at 4:55
Possible duplicate of Ignore changes to a tracked file
– Paul Crovella
Nov 14 '18 at 4:55
1
1
Possible duplicate of Can I 'git commit' a file and ignore its content changes?
– 1615903
Nov 14 '18 at 7:20
Possible duplicate of Can I 'git commit' a file and ignore its content changes?
– 1615903
Nov 14 '18 at 7:20
add a comment |
2 Answers
2
active
oldest
votes
- If you want the file to be removed altogether, you can delete the file locally, commit and push to master.
Remember, gitignore will only work for files, not yet pushed to remote. If already pushed to remote then, it will not work.
A gitignore file specifies intentionally untracked files that Git
should ignore. Files already tracked by Git are not affected
- If you want to keep the file in master and ignore only your local changes, you can update git exclude file located in
$GIT_DIR/info/exclude.
Read more information on gitignore
Read more information on ignore files locally in this stackoverflow Q&A
add a comment |
You cannot. Once the file is in Git repo it is in the Git repo. You have to remove the file from Git repo in order for .gitignore to kick in and start ignoring the file.
It is pretty simple - it is either the file is in repo and tracked. Or the file is not in the repo and not tracked.
.gitignore helps with the second case when there are files which are NOT in the repo and you do not want Git constantly reminding you that you might want to commit those files.
Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
– Isaac Sim
Nov 14 '18 at 5:08
No worries at all. The main thing we solved and explained your problem. Cheers!
– anvk
Nov 14 '18 at 12:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292720%2fgitignore-for-git-add%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
- If you want the file to be removed altogether, you can delete the file locally, commit and push to master.
Remember, gitignore will only work for files, not yet pushed to remote. If already pushed to remote then, it will not work.
A gitignore file specifies intentionally untracked files that Git
should ignore. Files already tracked by Git are not affected
- If you want to keep the file in master and ignore only your local changes, you can update git exclude file located in
$GIT_DIR/info/exclude.
Read more information on gitignore
Read more information on ignore files locally in this stackoverflow Q&A
add a comment |
- If you want the file to be removed altogether, you can delete the file locally, commit and push to master.
Remember, gitignore will only work for files, not yet pushed to remote. If already pushed to remote then, it will not work.
A gitignore file specifies intentionally untracked files that Git
should ignore. Files already tracked by Git are not affected
- If you want to keep the file in master and ignore only your local changes, you can update git exclude file located in
$GIT_DIR/info/exclude.
Read more information on gitignore
Read more information on ignore files locally in this stackoverflow Q&A
add a comment |
- If you want the file to be removed altogether, you can delete the file locally, commit and push to master.
Remember, gitignore will only work for files, not yet pushed to remote. If already pushed to remote then, it will not work.
A gitignore file specifies intentionally untracked files that Git
should ignore. Files already tracked by Git are not affected
- If you want to keep the file in master and ignore only your local changes, you can update git exclude file located in
$GIT_DIR/info/exclude.
Read more information on gitignore
Read more information on ignore files locally in this stackoverflow Q&A
- If you want the file to be removed altogether, you can delete the file locally, commit and push to master.
Remember, gitignore will only work for files, not yet pushed to remote. If already pushed to remote then, it will not work.
A gitignore file specifies intentionally untracked files that Git
should ignore. Files already tracked by Git are not affected
- If you want to keep the file in master and ignore only your local changes, you can update git exclude file located in
$GIT_DIR/info/exclude.
Read more information on gitignore
Read more information on ignore files locally in this stackoverflow Q&A
answered Nov 14 '18 at 4:30
Venkataraman R
1,464918
1,464918
add a comment |
add a comment |
You cannot. Once the file is in Git repo it is in the Git repo. You have to remove the file from Git repo in order for .gitignore to kick in and start ignoring the file.
It is pretty simple - it is either the file is in repo and tracked. Or the file is not in the repo and not tracked.
.gitignore helps with the second case when there are files which are NOT in the repo and you do not want Git constantly reminding you that you might want to commit those files.
Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
– Isaac Sim
Nov 14 '18 at 5:08
No worries at all. The main thing we solved and explained your problem. Cheers!
– anvk
Nov 14 '18 at 12:31
add a comment |
You cannot. Once the file is in Git repo it is in the Git repo. You have to remove the file from Git repo in order for .gitignore to kick in and start ignoring the file.
It is pretty simple - it is either the file is in repo and tracked. Or the file is not in the repo and not tracked.
.gitignore helps with the second case when there are files which are NOT in the repo and you do not want Git constantly reminding you that you might want to commit those files.
Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
– Isaac Sim
Nov 14 '18 at 5:08
No worries at all. The main thing we solved and explained your problem. Cheers!
– anvk
Nov 14 '18 at 12:31
add a comment |
You cannot. Once the file is in Git repo it is in the Git repo. You have to remove the file from Git repo in order for .gitignore to kick in and start ignoring the file.
It is pretty simple - it is either the file is in repo and tracked. Or the file is not in the repo and not tracked.
.gitignore helps with the second case when there are files which are NOT in the repo and you do not want Git constantly reminding you that you might want to commit those files.
You cannot. Once the file is in Git repo it is in the Git repo. You have to remove the file from Git repo in order for .gitignore to kick in and start ignoring the file.
It is pretty simple - it is either the file is in repo and tracked. Or the file is not in the repo and not tracked.
.gitignore helps with the second case when there are files which are NOT in the repo and you do not want Git constantly reminding you that you might want to commit those files.
answered Nov 14 '18 at 3:39
anvk
1,018810
1,018810
Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
– Isaac Sim
Nov 14 '18 at 5:08
No worries at all. The main thing we solved and explained your problem. Cheers!
– anvk
Nov 14 '18 at 12:31
add a comment |
Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
– Isaac Sim
Nov 14 '18 at 5:08
No worries at all. The main thing we solved and explained your problem. Cheers!
– anvk
Nov 14 '18 at 12:31
Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
– Isaac Sim
Nov 14 '18 at 5:08
Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
– Isaac Sim
Nov 14 '18 at 5:08
No worries at all. The main thing we solved and explained your problem. Cheers!
– anvk
Nov 14 '18 at 12:31
No worries at all. The main thing we solved and explained your problem. Cheers!
– anvk
Nov 14 '18 at 12:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292720%2fgitignore-for-git-add%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of Ignore changes to a tracked file
– Paul Crovella
Nov 14 '18 at 4:55
1
Possible duplicate of Can I 'git commit' a file and ignore its content changes?
– 1615903
Nov 14 '18 at 7:20