Git file statuses of files
According to the official git web site:
There are 4 states of files for git.
So the question is: what status have deleted and moved/renamed files?
Of course if the file is left in file system then after commit it will be untracked but before commit it has deleted status (for deletion). I think deletion is not really a file modification but an event.
git
add a comment |
According to the official git web site:
There are 4 states of files for git.
So the question is: what status have deleted and moved/renamed files?
Of course if the file is left in file system then after commit it will be untracked but before commit it has deleted status (for deletion). I think deletion is not really a file modification but an event.
git
Does the documentation surrounding this image suggest that these are the only statuses for a file? The documentation ongit status
perhaps indicates that there are others: git-scm.com/docs/git-status#_short_format ' ' = unmodified M = modified A = added D = deleted R = renamed C = copied U = updated but unmerged
– OliverRadini
Nov 14 '18 at 10:59
add a comment |
According to the official git web site:
There are 4 states of files for git.
So the question is: what status have deleted and moved/renamed files?
Of course if the file is left in file system then after commit it will be untracked but before commit it has deleted status (for deletion). I think deletion is not really a file modification but an event.
git
According to the official git web site:
There are 4 states of files for git.
So the question is: what status have deleted and moved/renamed files?
Of course if the file is left in file system then after commit it will be untracked but before commit it has deleted status (for deletion). I think deletion is not really a file modification but an event.
git
git
asked Nov 14 '18 at 10:55
Nikolai SletaNikolai Sleta
8618
8618
Does the documentation surrounding this image suggest that these are the only statuses for a file? The documentation ongit status
perhaps indicates that there are others: git-scm.com/docs/git-status#_short_format ' ' = unmodified M = modified A = added D = deleted R = renamed C = copied U = updated but unmerged
– OliverRadini
Nov 14 '18 at 10:59
add a comment |
Does the documentation surrounding this image suggest that these are the only statuses for a file? The documentation ongit status
perhaps indicates that there are others: git-scm.com/docs/git-status#_short_format ' ' = unmodified M = modified A = added D = deleted R = renamed C = copied U = updated but unmerged
– OliverRadini
Nov 14 '18 at 10:59
Does the documentation surrounding this image suggest that these are the only statuses for a file? The documentation on
git status
perhaps indicates that there are others: git-scm.com/docs/git-status#_short_format ' ' = unmodified M = modified A = added D = deleted R = renamed C = copied U = updated but unmerged– OliverRadini
Nov 14 '18 at 10:59
Does the documentation surrounding this image suggest that these are the only statuses for a file? The documentation on
git status
perhaps indicates that there are others: git-scm.com/docs/git-status#_short_format ' ' = unmodified M = modified A = added D = deleted R = renamed C = copied U = updated but unmerged– OliverRadini
Nov 14 '18 at 10:59
add a comment |
1 Answer
1
active
oldest
votes
You can consider a delete or a rename exactly like an edit in this diagram. It doesn't matter if you're making a content change (editing the file), making a metadata change (setting the file executable, for example) or deleting it, it goes through the same workflow.
If you have a file committed to git (in the teal "unmodified" state in your diagram) and you delete it, you are now in the "modified" state. git has detected this change:
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)
deleted: foo.txt
no changes added to commit (use "git add" and/or "git commit -a")
At this point the file is removed on-disk but not staged for deletion. It's in the yellow "modified" state. To stage it, you can stage it just like any other change, by running git add foo.txt
.
Recall, despite the name, git add
doesn't add a file, it stages the change to a file. In this case, the change is a delete, so git add
will stage a delete.
(I mention this only to prove a point, in fact, it's much more natural to run git rm
to stage a file's removal. Either will work.)
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: foo.txt
At this point, the file is in the red "staged" state. When you commit this change, the file will no longer exist in the repository.
[master 3b58d71] deleted
1 file changed, 7 deletions(-)
delete mode 100644 foo.txt
Recreating the file will start over in the grey "untracked" state.
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
foo.txt
nothing added to commit but untracked files present (use "git add" to track)
Thank you for such detailed answer
– Nikolai Sleta
Nov 14 '18 at 13:37
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%2f53298546%2fgit-file-statuses-of-files%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can consider a delete or a rename exactly like an edit in this diagram. It doesn't matter if you're making a content change (editing the file), making a metadata change (setting the file executable, for example) or deleting it, it goes through the same workflow.
If you have a file committed to git (in the teal "unmodified" state in your diagram) and you delete it, you are now in the "modified" state. git has detected this change:
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)
deleted: foo.txt
no changes added to commit (use "git add" and/or "git commit -a")
At this point the file is removed on-disk but not staged for deletion. It's in the yellow "modified" state. To stage it, you can stage it just like any other change, by running git add foo.txt
.
Recall, despite the name, git add
doesn't add a file, it stages the change to a file. In this case, the change is a delete, so git add
will stage a delete.
(I mention this only to prove a point, in fact, it's much more natural to run git rm
to stage a file's removal. Either will work.)
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: foo.txt
At this point, the file is in the red "staged" state. When you commit this change, the file will no longer exist in the repository.
[master 3b58d71] deleted
1 file changed, 7 deletions(-)
delete mode 100644 foo.txt
Recreating the file will start over in the grey "untracked" state.
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
foo.txt
nothing added to commit but untracked files present (use "git add" to track)
Thank you for such detailed answer
– Nikolai Sleta
Nov 14 '18 at 13:37
add a comment |
You can consider a delete or a rename exactly like an edit in this diagram. It doesn't matter if you're making a content change (editing the file), making a metadata change (setting the file executable, for example) or deleting it, it goes through the same workflow.
If you have a file committed to git (in the teal "unmodified" state in your diagram) and you delete it, you are now in the "modified" state. git has detected this change:
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)
deleted: foo.txt
no changes added to commit (use "git add" and/or "git commit -a")
At this point the file is removed on-disk but not staged for deletion. It's in the yellow "modified" state. To stage it, you can stage it just like any other change, by running git add foo.txt
.
Recall, despite the name, git add
doesn't add a file, it stages the change to a file. In this case, the change is a delete, so git add
will stage a delete.
(I mention this only to prove a point, in fact, it's much more natural to run git rm
to stage a file's removal. Either will work.)
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: foo.txt
At this point, the file is in the red "staged" state. When you commit this change, the file will no longer exist in the repository.
[master 3b58d71] deleted
1 file changed, 7 deletions(-)
delete mode 100644 foo.txt
Recreating the file will start over in the grey "untracked" state.
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
foo.txt
nothing added to commit but untracked files present (use "git add" to track)
Thank you for such detailed answer
– Nikolai Sleta
Nov 14 '18 at 13:37
add a comment |
You can consider a delete or a rename exactly like an edit in this diagram. It doesn't matter if you're making a content change (editing the file), making a metadata change (setting the file executable, for example) or deleting it, it goes through the same workflow.
If you have a file committed to git (in the teal "unmodified" state in your diagram) and you delete it, you are now in the "modified" state. git has detected this change:
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)
deleted: foo.txt
no changes added to commit (use "git add" and/or "git commit -a")
At this point the file is removed on-disk but not staged for deletion. It's in the yellow "modified" state. To stage it, you can stage it just like any other change, by running git add foo.txt
.
Recall, despite the name, git add
doesn't add a file, it stages the change to a file. In this case, the change is a delete, so git add
will stage a delete.
(I mention this only to prove a point, in fact, it's much more natural to run git rm
to stage a file's removal. Either will work.)
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: foo.txt
At this point, the file is in the red "staged" state. When you commit this change, the file will no longer exist in the repository.
[master 3b58d71] deleted
1 file changed, 7 deletions(-)
delete mode 100644 foo.txt
Recreating the file will start over in the grey "untracked" state.
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
foo.txt
nothing added to commit but untracked files present (use "git add" to track)
You can consider a delete or a rename exactly like an edit in this diagram. It doesn't matter if you're making a content change (editing the file), making a metadata change (setting the file executable, for example) or deleting it, it goes through the same workflow.
If you have a file committed to git (in the teal "unmodified" state in your diagram) and you delete it, you are now in the "modified" state. git has detected this change:
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)
deleted: foo.txt
no changes added to commit (use "git add" and/or "git commit -a")
At this point the file is removed on-disk but not staged for deletion. It's in the yellow "modified" state. To stage it, you can stage it just like any other change, by running git add foo.txt
.
Recall, despite the name, git add
doesn't add a file, it stages the change to a file. In this case, the change is a delete, so git add
will stage a delete.
(I mention this only to prove a point, in fact, it's much more natural to run git rm
to stage a file's removal. Either will work.)
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: foo.txt
At this point, the file is in the red "staged" state. When you commit this change, the file will no longer exist in the repository.
[master 3b58d71] deleted
1 file changed, 7 deletions(-)
delete mode 100644 foo.txt
Recreating the file will start over in the grey "untracked" state.
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
foo.txt
nothing added to commit but untracked files present (use "git add" to track)
answered Nov 14 '18 at 12:38
Edward ThomsonEdward Thomson
49.8k9102141
49.8k9102141
Thank you for such detailed answer
– Nikolai Sleta
Nov 14 '18 at 13:37
add a comment |
Thank you for such detailed answer
– Nikolai Sleta
Nov 14 '18 at 13:37
Thank you for such detailed answer
– Nikolai Sleta
Nov 14 '18 at 13:37
Thank you for such detailed answer
– Nikolai Sleta
Nov 14 '18 at 13:37
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.
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%2f53298546%2fgit-file-statuses-of-files%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
Does the documentation surrounding this image suggest that these are the only statuses for a file? The documentation on
git status
perhaps indicates that there are others: git-scm.com/docs/git-status#_short_format ' ' = unmodified M = modified A = added D = deleted R = renamed C = copied U = updated but unmerged– OliverRadini
Nov 14 '18 at 10:59