upstream deleted files showing as added in git diffHow to remove local (untracked) files from the current Git working tree?What is the difference between 'git pull' and 'git fetch'?How do I undo 'git add' before commit?How do I undo the most recent local commits in Git?How do I force “git pull” to overwrite local files?How do I show the changes which have been staged?How do I check out a remote Git branch?How do I delete a Git branch locally and remotely?How do I revert a Git repository to a previous commit?How do I rename a local Git branch?
Why didn't Caesar move against Sextus Pompey immediately after Munda?
How would one prevent political gerrymandering?
Robots in a spaceship
Equatorial oceanic river caused by tides
What election rules and voting rights are guaranteed by the US Constitution?
Why would Dementors torture a Death Eater if they are loyal to Voldemort?
Magento2: Custom module not working
How does the 'five minute adventuring day' affect class balance?
Where can I find my serialized Sitecore items?
Is leaving out prefixes like "rauf", "rüber", "rein" when describing movement considered a big mistake in spoken German?
How useful would a hydroelectric power plant be in the post-apocalypse world?
Reusable spacecraft: why still have fairings detach, instead of open/close?
"I am [the / an] owner of a bookstore"?
What was the point of separating stdout and stderr?
The alcoholic village festival
How do I keep a running total of data in a column in Excel?
Why did the Apple //e make a hideous noise if you inserted the disk upside down?
Why isn't UDP with reliability (implemented at Application layer) a substitute of TCP?
What was the first science fiction or fantasy multiple choice book?
How far can gerrymandering go?
How do I present a future free of gender stereotypes without being jarring or overpowering the narrative?
Early 2000s movie about time travel, protagonist travels back to save girlfriend, then into multiple points in future
Meaning of the word "good" in context
Tricolour nonogram
upstream deleted files showing as added in git diff
How to remove local (untracked) files from the current Git working tree?What is the difference between 'git pull' and 'git fetch'?How do I undo 'git add' before commit?How do I undo the most recent local commits in Git?How do I force “git pull” to overwrite local files?How do I show the changes which have been staged?How do I check out a remote Git branch?How do I delete a Git branch locally and remotely?How do I revert a Git repository to a previous commit?How do I rename a local Git branch?
In the PR interface on GitHub, I can see the new changes that I've made to my branch as a diff against the master branch.
I'd like to get a list of these files from the command line.
An issue arises (on the command line) when a file was deleted on the target branch I'm diffing against (e.g. master
) but my branch isn't aware of this change.
- Create git repo and add file
a
tomaster
. - Create branch
add-b
frommaster
and add a fileb
. Don't merge. - Switch back to
master
and removea
. Commit. - Switch back to branch
add-b
and rungit diff --name-only --diff-filter=A master
, which shows botha
andb
as having been added.
Given that git checkout master && git merge add-b
will not re-add the file a
to the repo, I understand there must be some mechanism whereby git figures this out and imagine there is a way to bubble up this information.
What command(s) must I run to only show added / modified files, and avoid ones that have been deleted on the target branch?
Edit - example for clarity
• ~/src/git-testing $$$ git init
Initialized empty Git repository in /Users/ryan.tuck/src/git-testing/.git/
• ~/src/git-testing $$$ touch a && git add . && git commit -m 'add a'
[master (root-commit) f65661b] add a
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a
• ~/src/git-testing $$$ git checkout -b add-b
Switched to a new branch 'add-b'
• ~/src/git-testing $$$ touch b
• ~/src/git-testing $$$ git add . && git commit -m 'add b'
[add-b 588960f] add b
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 b
• ~/src/git-testing $$$ ls
a b
• ~/src/git-testing $$$ git checkout master
Switched to branch 'master'
• ~/src/git-testing $$$ ls
a
• ~/src/git-testing $$$ rm a && git add . && git commit -m 'remove a'
[master 2b4d9f8] remove a
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 a
• ~/src/git-testing $$$ ls
• ~/src/git-testing $$$ git checkout add-b
Switched to branch 'add-b'
• ~/src/git-testing $$$ git diff --name-only --diff-filter=A master
a
b
git
add a comment |
In the PR interface on GitHub, I can see the new changes that I've made to my branch as a diff against the master branch.
I'd like to get a list of these files from the command line.
An issue arises (on the command line) when a file was deleted on the target branch I'm diffing against (e.g. master
) but my branch isn't aware of this change.
- Create git repo and add file
a
tomaster
. - Create branch
add-b
frommaster
and add a fileb
. Don't merge. - Switch back to
master
and removea
. Commit. - Switch back to branch
add-b
and rungit diff --name-only --diff-filter=A master
, which shows botha
andb
as having been added.
Given that git checkout master && git merge add-b
will not re-add the file a
to the repo, I understand there must be some mechanism whereby git figures this out and imagine there is a way to bubble up this information.
What command(s) must I run to only show added / modified files, and avoid ones that have been deleted on the target branch?
Edit - example for clarity
• ~/src/git-testing $$$ git init
Initialized empty Git repository in /Users/ryan.tuck/src/git-testing/.git/
• ~/src/git-testing $$$ touch a && git add . && git commit -m 'add a'
[master (root-commit) f65661b] add a
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a
• ~/src/git-testing $$$ git checkout -b add-b
Switched to a new branch 'add-b'
• ~/src/git-testing $$$ touch b
• ~/src/git-testing $$$ git add . && git commit -m 'add b'
[add-b 588960f] add b
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 b
• ~/src/git-testing $$$ ls
a b
• ~/src/git-testing $$$ git checkout master
Switched to branch 'master'
• ~/src/git-testing $$$ ls
a
• ~/src/git-testing $$$ rm a && git add . && git commit -m 'remove a'
[master 2b4d9f8] remove a
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 a
• ~/src/git-testing $$$ ls
• ~/src/git-testing $$$ git checkout add-b
Switched to branch 'add-b'
• ~/src/git-testing $$$ git diff --name-only --diff-filter=A master
a
b
git
I guess on step 3 you created rm-a from master as well, is that right?
– eftshift0
Mar 25 at 16:21
add a comment |
In the PR interface on GitHub, I can see the new changes that I've made to my branch as a diff against the master branch.
I'd like to get a list of these files from the command line.
An issue arises (on the command line) when a file was deleted on the target branch I'm diffing against (e.g. master
) but my branch isn't aware of this change.
- Create git repo and add file
a
tomaster
. - Create branch
add-b
frommaster
and add a fileb
. Don't merge. - Switch back to
master
and removea
. Commit. - Switch back to branch
add-b
and rungit diff --name-only --diff-filter=A master
, which shows botha
andb
as having been added.
Given that git checkout master && git merge add-b
will not re-add the file a
to the repo, I understand there must be some mechanism whereby git figures this out and imagine there is a way to bubble up this information.
What command(s) must I run to only show added / modified files, and avoid ones that have been deleted on the target branch?
Edit - example for clarity
• ~/src/git-testing $$$ git init
Initialized empty Git repository in /Users/ryan.tuck/src/git-testing/.git/
• ~/src/git-testing $$$ touch a && git add . && git commit -m 'add a'
[master (root-commit) f65661b] add a
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a
• ~/src/git-testing $$$ git checkout -b add-b
Switched to a new branch 'add-b'
• ~/src/git-testing $$$ touch b
• ~/src/git-testing $$$ git add . && git commit -m 'add b'
[add-b 588960f] add b
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 b
• ~/src/git-testing $$$ ls
a b
• ~/src/git-testing $$$ git checkout master
Switched to branch 'master'
• ~/src/git-testing $$$ ls
a
• ~/src/git-testing $$$ rm a && git add . && git commit -m 'remove a'
[master 2b4d9f8] remove a
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 a
• ~/src/git-testing $$$ ls
• ~/src/git-testing $$$ git checkout add-b
Switched to branch 'add-b'
• ~/src/git-testing $$$ git diff --name-only --diff-filter=A master
a
b
git
In the PR interface on GitHub, I can see the new changes that I've made to my branch as a diff against the master branch.
I'd like to get a list of these files from the command line.
An issue arises (on the command line) when a file was deleted on the target branch I'm diffing against (e.g. master
) but my branch isn't aware of this change.
- Create git repo and add file
a
tomaster
. - Create branch
add-b
frommaster
and add a fileb
. Don't merge. - Switch back to
master
and removea
. Commit. - Switch back to branch
add-b
and rungit diff --name-only --diff-filter=A master
, which shows botha
andb
as having been added.
Given that git checkout master && git merge add-b
will not re-add the file a
to the repo, I understand there must be some mechanism whereby git figures this out and imagine there is a way to bubble up this information.
What command(s) must I run to only show added / modified files, and avoid ones that have been deleted on the target branch?
Edit - example for clarity
• ~/src/git-testing $$$ git init
Initialized empty Git repository in /Users/ryan.tuck/src/git-testing/.git/
• ~/src/git-testing $$$ touch a && git add . && git commit -m 'add a'
[master (root-commit) f65661b] add a
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a
• ~/src/git-testing $$$ git checkout -b add-b
Switched to a new branch 'add-b'
• ~/src/git-testing $$$ touch b
• ~/src/git-testing $$$ git add . && git commit -m 'add b'
[add-b 588960f] add b
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 b
• ~/src/git-testing $$$ ls
a b
• ~/src/git-testing $$$ git checkout master
Switched to branch 'master'
• ~/src/git-testing $$$ ls
a
• ~/src/git-testing $$$ rm a && git add . && git commit -m 'remove a'
[master 2b4d9f8] remove a
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 a
• ~/src/git-testing $$$ ls
• ~/src/git-testing $$$ git checkout add-b
Switched to branch 'add-b'
• ~/src/git-testing $$$ git diff --name-only --diff-filter=A master
a
b
git
git
edited Mar 25 at 16:27
Ryan Tuck
asked Mar 25 at 15:48
Ryan TuckRyan Tuck
2,2583 gold badges32 silver badges49 bronze badges
2,2583 gold badges32 silver badges49 bronze badges
I guess on step 3 you created rm-a from master as well, is that right?
– eftshift0
Mar 25 at 16:21
add a comment |
I guess on step 3 you created rm-a from master as well, is that right?
– eftshift0
Mar 25 at 16:21
I guess on step 3 you created rm-a from master as well, is that right?
– eftshift0
Mar 25 at 16:21
I guess on step 3 you created rm-a from master as well, is that right?
– eftshift0
Mar 25 at 16:21
add a comment |
1 Answer
1
active
oldest
votes
I think there's no magic in what you are asking there. master has no files, and add-b has both a and b.... so both files have to be added for the diff to make sense..... are you struggling because you think that git is somehow considering the history of a and b (files) when comparing the branches? I don't think that is the case.... not on this example, anyway. Perhaps you would like to use something more like the diff since both branches diverged? If that's the case, try with ...:
git diff master...add-b
That should show you only the addition of b.
this was exactly what i was looking for to get justb
to show up - thanks!
– Ryan Tuck
Mar 25 at 18:13
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%2f55341621%2fupstream-deleted-files-showing-as-added-in-git-diff%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
I think there's no magic in what you are asking there. master has no files, and add-b has both a and b.... so both files have to be added for the diff to make sense..... are you struggling because you think that git is somehow considering the history of a and b (files) when comparing the branches? I don't think that is the case.... not on this example, anyway. Perhaps you would like to use something more like the diff since both branches diverged? If that's the case, try with ...:
git diff master...add-b
That should show you only the addition of b.
this was exactly what i was looking for to get justb
to show up - thanks!
– Ryan Tuck
Mar 25 at 18:13
add a comment |
I think there's no magic in what you are asking there. master has no files, and add-b has both a and b.... so both files have to be added for the diff to make sense..... are you struggling because you think that git is somehow considering the history of a and b (files) when comparing the branches? I don't think that is the case.... not on this example, anyway. Perhaps you would like to use something more like the diff since both branches diverged? If that's the case, try with ...:
git diff master...add-b
That should show you only the addition of b.
this was exactly what i was looking for to get justb
to show up - thanks!
– Ryan Tuck
Mar 25 at 18:13
add a comment |
I think there's no magic in what you are asking there. master has no files, and add-b has both a and b.... so both files have to be added for the diff to make sense..... are you struggling because you think that git is somehow considering the history of a and b (files) when comparing the branches? I don't think that is the case.... not on this example, anyway. Perhaps you would like to use something more like the diff since both branches diverged? If that's the case, try with ...:
git diff master...add-b
That should show you only the addition of b.
I think there's no magic in what you are asking there. master has no files, and add-b has both a and b.... so both files have to be added for the diff to make sense..... are you struggling because you think that git is somehow considering the history of a and b (files) when comparing the branches? I don't think that is the case.... not on this example, anyway. Perhaps you would like to use something more like the diff since both branches diverged? If that's the case, try with ...:
git diff master...add-b
That should show you only the addition of b.
answered Mar 25 at 16:25
eftshift0eftshift0
7,3261 gold badge12 silver badges22 bronze badges
7,3261 gold badge12 silver badges22 bronze badges
this was exactly what i was looking for to get justb
to show up - thanks!
– Ryan Tuck
Mar 25 at 18:13
add a comment |
this was exactly what i was looking for to get justb
to show up - thanks!
– Ryan Tuck
Mar 25 at 18:13
this was exactly what i was looking for to get just
b
to show up - thanks!– Ryan Tuck
Mar 25 at 18:13
this was exactly what i was looking for to get just
b
to show up - thanks!– Ryan Tuck
Mar 25 at 18:13
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
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%2f55341621%2fupstream-deleted-files-showing-as-added-in-git-diff%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
I guess on step 3 you created rm-a from master as well, is that right?
– eftshift0
Mar 25 at 16:21