how to keep two separate working directories in sync — or is git able to recognize identical commits?










1















  1. (in some working directory A) I did some local changes and performed add and commit

  2. (in some working directory B) I got a patch for these local changes (in directory A) and applied it in directory B. I performed add/commit/push in directory B.

  3. (in the working directory A) I performed a git pull and expected my local commit to disappear. It did not.

  4. (in the working directory A) I performed a git reset HEAD~. git diff shows the changes which are already pushed earlier. (forget about this point -- this was my attempt to solve this problem)

Obviously I did something wrong. what is it?










share|improve this question
























  • You mention working directories, but what about the underlying Git directory or directories? Are you using git worktree add to create the additional working directories?

    – torek
    Nov 13 '18 at 16:58











  • the directories are on different machines

    – Frank Puck
    Nov 13 '18 at 16:59











  • Ah, OK, that clarifies things.

    – torek
    Nov 13 '18 at 17:06















1















  1. (in some working directory A) I did some local changes and performed add and commit

  2. (in some working directory B) I got a patch for these local changes (in directory A) and applied it in directory B. I performed add/commit/push in directory B.

  3. (in the working directory A) I performed a git pull and expected my local commit to disappear. It did not.

  4. (in the working directory A) I performed a git reset HEAD~. git diff shows the changes which are already pushed earlier. (forget about this point -- this was my attempt to solve this problem)

Obviously I did something wrong. what is it?










share|improve this question
























  • You mention working directories, but what about the underlying Git directory or directories? Are you using git worktree add to create the additional working directories?

    – torek
    Nov 13 '18 at 16:58











  • the directories are on different machines

    – Frank Puck
    Nov 13 '18 at 16:59











  • Ah, OK, that clarifies things.

    – torek
    Nov 13 '18 at 17:06













1












1








1








  1. (in some working directory A) I did some local changes and performed add and commit

  2. (in some working directory B) I got a patch for these local changes (in directory A) and applied it in directory B. I performed add/commit/push in directory B.

  3. (in the working directory A) I performed a git pull and expected my local commit to disappear. It did not.

  4. (in the working directory A) I performed a git reset HEAD~. git diff shows the changes which are already pushed earlier. (forget about this point -- this was my attempt to solve this problem)

Obviously I did something wrong. what is it?










share|improve this question
















  1. (in some working directory A) I did some local changes and performed add and commit

  2. (in some working directory B) I got a patch for these local changes (in directory A) and applied it in directory B. I performed add/commit/push in directory B.

  3. (in the working directory A) I performed a git pull and expected my local commit to disappear. It did not.

  4. (in the working directory A) I performed a git reset HEAD~. git diff shows the changes which are already pushed earlier. (forget about this point -- this was my attempt to solve this problem)

Obviously I did something wrong. what is it?







git






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 17:04







Frank Puck

















asked Nov 13 '18 at 16:56









Frank PuckFrank Puck

12910




12910












  • You mention working directories, but what about the underlying Git directory or directories? Are you using git worktree add to create the additional working directories?

    – torek
    Nov 13 '18 at 16:58











  • the directories are on different machines

    – Frank Puck
    Nov 13 '18 at 16:59











  • Ah, OK, that clarifies things.

    – torek
    Nov 13 '18 at 17:06

















  • You mention working directories, but what about the underlying Git directory or directories? Are you using git worktree add to create the additional working directories?

    – torek
    Nov 13 '18 at 16:58











  • the directories are on different machines

    – Frank Puck
    Nov 13 '18 at 16:59











  • Ah, OK, that clarifies things.

    – torek
    Nov 13 '18 at 17:06
















You mention working directories, but what about the underlying Git directory or directories? Are you using git worktree add to create the additional working directories?

– torek
Nov 13 '18 at 16:58





You mention working directories, but what about the underlying Git directory or directories? Are you using git worktree add to create the additional working directories?

– torek
Nov 13 '18 at 16:58













the directories are on different machines

– Frank Puck
Nov 13 '18 at 16:59





the directories are on different machines

– Frank Puck
Nov 13 '18 at 16:59













Ah, OK, that clarifies things.

– torek
Nov 13 '18 at 17:06





Ah, OK, that clarifies things.

– torek
Nov 13 '18 at 17:06












3 Answers
3






active

oldest

votes


















0














This is what I think you described:
On machine 1 make commit X
On machine 2 apply a patch which does the same thing, and create commit X'
Push commit X'



On machine 1 pull commit X'
Machine 1 now has 2 commits: X and X'



You reset HEAD~ on machine 1, removing commit X', and leaving commit X.



The pull is a fetch followed by a merge.My understanding is that in a merge git can recognize identical changes.



Still, it might be interesting to do the pull again, and run
git show HEAD
to see what was committed.
Perhaps it's a merge commit with very little content?
Someone with more plumbing knowledge could answer that better that I can.
It is likely to depend on what you merge settings are also. Merge, rebase?






share|improve this answer























  • I understood your answer until/including "you reset". Then I'm lost. Are you suggesting I should have performed a git merge?

    – Frank Puck
    Nov 13 '18 at 20:11











  • what I meant to imply is that I expected the duplicate commit to be ignored because the content is already there. The experiment is proposed was to run git show HEAD, do the pull again, and run git show HEAD again, to see if there is any difference.

    – Randy Leberknight
    Nov 14 '18 at 18:26



















0














There are many ways to look at how you might coordinate the content across two machines' working directories.



The most basic is: if you committed changes on machine A, and want them on machine B, you can fetch them from A to B so that A and B will have the patch via the same commit. Sometimes that's not a suitable answer, and so other ways are possible. But which one makes sense for what you're doing depends on what you're doing, and we don't know enough to necessarily address that yet.



So we can follow up on that if it makes sense, but let's start by clarifying a possible conceptual misunderstanding:




(in the working directory A) I performed a git pull and expected my local commit to disappear. It did not.




My question would be, why is that the expected behavior? In general, you don't want your local changes to disappear when you pull in remote changes; instead you want to combine them.



Now, in the specific case where the local changes and the remote changes are identical, you might indeed want the local changes to go away, and if you rebase the local changes onto the newly-fetched remote changes then that is what should happen.



git pull --rebase


Now if, in the process of rebasing your local changes onto the fetched changes, git finds that a local commit's patch is exactly the same as the patch for one of the fetched commits, the local commit will be discarded.



Perhaps you expected that behavior because in the past you've used repos configured to rebase on pull by default? Be aware that auto-rebasing is documented as a "potentially dangerous" feature, so you might want to consider if it's really the best default; but if it is the default you want, look up pull.rebase in the git config docs: https://git-scm.com/docs/git-config






share|improve this answer























  • are you saying the answer is the parameter --rebase for git pull?

    – Frank Puck
    Nov 13 '18 at 20:55











  • yes -- I expected this to be merged automatically. One reason for this is, that I cannot imagine multiple unnamed tips of a source code control system. And I was told, that --rebase is only cosmetic to reorder local commits to come after remote commits. The basic problem is, that git is basically undocumented (and also bad designed).

    – Frank Puck
    Nov 13 '18 at 21:05











  • from the man page: "More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase, it runs git rebase instead of git merge."

    – Frank Puck
    Nov 13 '18 at 21:15











  • @FrankPuck - Ok... taking those one at a time. First: No, I am not saying that "the answer" is the parameter --rebase; if I were saying that's the answer, my answer would be quite a lot shorter.

    – Mark Adelsberger
    Nov 14 '18 at 0:43











  • @FrankPuck - Expecting pull to merge automatically - which it does - is not the same as expecting the commit you made to be gone - which would only happen under specific conditions, including that you use the --rebase option. git is neither undocumented in this behavior, nor poorly designed.

    – Mark Adelsberger
    Nov 14 '18 at 0:44


















0














You can do it with a git pull, but I would use rsync



cd directory_A; rsync -mauvPAX directory_B/ .


This would efficiently duplicate the content of directory_B into directory_A and preserve any files in directory_A that are missing from directory_B.



If you want to scrub any additional files from directory_A that aren't in directory_B then include the --delete flag.






share|improve this answer






















    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
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285972%2fhow-to-keep-two-separate-working-directories-in-sync-or-is-git-able-to-recogn%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    This is what I think you described:
    On machine 1 make commit X
    On machine 2 apply a patch which does the same thing, and create commit X'
    Push commit X'



    On machine 1 pull commit X'
    Machine 1 now has 2 commits: X and X'



    You reset HEAD~ on machine 1, removing commit X', and leaving commit X.



    The pull is a fetch followed by a merge.My understanding is that in a merge git can recognize identical changes.



    Still, it might be interesting to do the pull again, and run
    git show HEAD
    to see what was committed.
    Perhaps it's a merge commit with very little content?
    Someone with more plumbing knowledge could answer that better that I can.
    It is likely to depend on what you merge settings are also. Merge, rebase?






    share|improve this answer























    • I understood your answer until/including "you reset". Then I'm lost. Are you suggesting I should have performed a git merge?

      – Frank Puck
      Nov 13 '18 at 20:11











    • what I meant to imply is that I expected the duplicate commit to be ignored because the content is already there. The experiment is proposed was to run git show HEAD, do the pull again, and run git show HEAD again, to see if there is any difference.

      – Randy Leberknight
      Nov 14 '18 at 18:26
















    0














    This is what I think you described:
    On machine 1 make commit X
    On machine 2 apply a patch which does the same thing, and create commit X'
    Push commit X'



    On machine 1 pull commit X'
    Machine 1 now has 2 commits: X and X'



    You reset HEAD~ on machine 1, removing commit X', and leaving commit X.



    The pull is a fetch followed by a merge.My understanding is that in a merge git can recognize identical changes.



    Still, it might be interesting to do the pull again, and run
    git show HEAD
    to see what was committed.
    Perhaps it's a merge commit with very little content?
    Someone with more plumbing knowledge could answer that better that I can.
    It is likely to depend on what you merge settings are also. Merge, rebase?






    share|improve this answer























    • I understood your answer until/including "you reset". Then I'm lost. Are you suggesting I should have performed a git merge?

      – Frank Puck
      Nov 13 '18 at 20:11











    • what I meant to imply is that I expected the duplicate commit to be ignored because the content is already there. The experiment is proposed was to run git show HEAD, do the pull again, and run git show HEAD again, to see if there is any difference.

      – Randy Leberknight
      Nov 14 '18 at 18:26














    0












    0








    0







    This is what I think you described:
    On machine 1 make commit X
    On machine 2 apply a patch which does the same thing, and create commit X'
    Push commit X'



    On machine 1 pull commit X'
    Machine 1 now has 2 commits: X and X'



    You reset HEAD~ on machine 1, removing commit X', and leaving commit X.



    The pull is a fetch followed by a merge.My understanding is that in a merge git can recognize identical changes.



    Still, it might be interesting to do the pull again, and run
    git show HEAD
    to see what was committed.
    Perhaps it's a merge commit with very little content?
    Someone with more plumbing knowledge could answer that better that I can.
    It is likely to depend on what you merge settings are also. Merge, rebase?






    share|improve this answer













    This is what I think you described:
    On machine 1 make commit X
    On machine 2 apply a patch which does the same thing, and create commit X'
    Push commit X'



    On machine 1 pull commit X'
    Machine 1 now has 2 commits: X and X'



    You reset HEAD~ on machine 1, removing commit X', and leaving commit X.



    The pull is a fetch followed by a merge.My understanding is that in a merge git can recognize identical changes.



    Still, it might be interesting to do the pull again, and run
    git show HEAD
    to see what was committed.
    Perhaps it's a merge commit with very little content?
    Someone with more plumbing knowledge could answer that better that I can.
    It is likely to depend on what you merge settings are also. Merge, rebase?







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 13 '18 at 18:26









    Randy LeberknightRandy Leberknight

    739412




    739412












    • I understood your answer until/including "you reset". Then I'm lost. Are you suggesting I should have performed a git merge?

      – Frank Puck
      Nov 13 '18 at 20:11











    • what I meant to imply is that I expected the duplicate commit to be ignored because the content is already there. The experiment is proposed was to run git show HEAD, do the pull again, and run git show HEAD again, to see if there is any difference.

      – Randy Leberknight
      Nov 14 '18 at 18:26


















    • I understood your answer until/including "you reset". Then I'm lost. Are you suggesting I should have performed a git merge?

      – Frank Puck
      Nov 13 '18 at 20:11











    • what I meant to imply is that I expected the duplicate commit to be ignored because the content is already there. The experiment is proposed was to run git show HEAD, do the pull again, and run git show HEAD again, to see if there is any difference.

      – Randy Leberknight
      Nov 14 '18 at 18:26

















    I understood your answer until/including "you reset". Then I'm lost. Are you suggesting I should have performed a git merge?

    – Frank Puck
    Nov 13 '18 at 20:11





    I understood your answer until/including "you reset". Then I'm lost. Are you suggesting I should have performed a git merge?

    – Frank Puck
    Nov 13 '18 at 20:11













    what I meant to imply is that I expected the duplicate commit to be ignored because the content is already there. The experiment is proposed was to run git show HEAD, do the pull again, and run git show HEAD again, to see if there is any difference.

    – Randy Leberknight
    Nov 14 '18 at 18:26






    what I meant to imply is that I expected the duplicate commit to be ignored because the content is already there. The experiment is proposed was to run git show HEAD, do the pull again, and run git show HEAD again, to see if there is any difference.

    – Randy Leberknight
    Nov 14 '18 at 18:26














    0














    There are many ways to look at how you might coordinate the content across two machines' working directories.



    The most basic is: if you committed changes on machine A, and want them on machine B, you can fetch them from A to B so that A and B will have the patch via the same commit. Sometimes that's not a suitable answer, and so other ways are possible. But which one makes sense for what you're doing depends on what you're doing, and we don't know enough to necessarily address that yet.



    So we can follow up on that if it makes sense, but let's start by clarifying a possible conceptual misunderstanding:




    (in the working directory A) I performed a git pull and expected my local commit to disappear. It did not.




    My question would be, why is that the expected behavior? In general, you don't want your local changes to disappear when you pull in remote changes; instead you want to combine them.



    Now, in the specific case where the local changes and the remote changes are identical, you might indeed want the local changes to go away, and if you rebase the local changes onto the newly-fetched remote changes then that is what should happen.



    git pull --rebase


    Now if, in the process of rebasing your local changes onto the fetched changes, git finds that a local commit's patch is exactly the same as the patch for one of the fetched commits, the local commit will be discarded.



    Perhaps you expected that behavior because in the past you've used repos configured to rebase on pull by default? Be aware that auto-rebasing is documented as a "potentially dangerous" feature, so you might want to consider if it's really the best default; but if it is the default you want, look up pull.rebase in the git config docs: https://git-scm.com/docs/git-config






    share|improve this answer























    • are you saying the answer is the parameter --rebase for git pull?

      – Frank Puck
      Nov 13 '18 at 20:55











    • yes -- I expected this to be merged automatically. One reason for this is, that I cannot imagine multiple unnamed tips of a source code control system. And I was told, that --rebase is only cosmetic to reorder local commits to come after remote commits. The basic problem is, that git is basically undocumented (and also bad designed).

      – Frank Puck
      Nov 13 '18 at 21:05











    • from the man page: "More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase, it runs git rebase instead of git merge."

      – Frank Puck
      Nov 13 '18 at 21:15











    • @FrankPuck - Ok... taking those one at a time. First: No, I am not saying that "the answer" is the parameter --rebase; if I were saying that's the answer, my answer would be quite a lot shorter.

      – Mark Adelsberger
      Nov 14 '18 at 0:43











    • @FrankPuck - Expecting pull to merge automatically - which it does - is not the same as expecting the commit you made to be gone - which would only happen under specific conditions, including that you use the --rebase option. git is neither undocumented in this behavior, nor poorly designed.

      – Mark Adelsberger
      Nov 14 '18 at 0:44















    0














    There are many ways to look at how you might coordinate the content across two machines' working directories.



    The most basic is: if you committed changes on machine A, and want them on machine B, you can fetch them from A to B so that A and B will have the patch via the same commit. Sometimes that's not a suitable answer, and so other ways are possible. But which one makes sense for what you're doing depends on what you're doing, and we don't know enough to necessarily address that yet.



    So we can follow up on that if it makes sense, but let's start by clarifying a possible conceptual misunderstanding:




    (in the working directory A) I performed a git pull and expected my local commit to disappear. It did not.




    My question would be, why is that the expected behavior? In general, you don't want your local changes to disappear when you pull in remote changes; instead you want to combine them.



    Now, in the specific case where the local changes and the remote changes are identical, you might indeed want the local changes to go away, and if you rebase the local changes onto the newly-fetched remote changes then that is what should happen.



    git pull --rebase


    Now if, in the process of rebasing your local changes onto the fetched changes, git finds that a local commit's patch is exactly the same as the patch for one of the fetched commits, the local commit will be discarded.



    Perhaps you expected that behavior because in the past you've used repos configured to rebase on pull by default? Be aware that auto-rebasing is documented as a "potentially dangerous" feature, so you might want to consider if it's really the best default; but if it is the default you want, look up pull.rebase in the git config docs: https://git-scm.com/docs/git-config






    share|improve this answer























    • are you saying the answer is the parameter --rebase for git pull?

      – Frank Puck
      Nov 13 '18 at 20:55











    • yes -- I expected this to be merged automatically. One reason for this is, that I cannot imagine multiple unnamed tips of a source code control system. And I was told, that --rebase is only cosmetic to reorder local commits to come after remote commits. The basic problem is, that git is basically undocumented (and also bad designed).

      – Frank Puck
      Nov 13 '18 at 21:05











    • from the man page: "More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase, it runs git rebase instead of git merge."

      – Frank Puck
      Nov 13 '18 at 21:15











    • @FrankPuck - Ok... taking those one at a time. First: No, I am not saying that "the answer" is the parameter --rebase; if I were saying that's the answer, my answer would be quite a lot shorter.

      – Mark Adelsberger
      Nov 14 '18 at 0:43











    • @FrankPuck - Expecting pull to merge automatically - which it does - is not the same as expecting the commit you made to be gone - which would only happen under specific conditions, including that you use the --rebase option. git is neither undocumented in this behavior, nor poorly designed.

      – Mark Adelsberger
      Nov 14 '18 at 0:44













    0












    0








    0







    There are many ways to look at how you might coordinate the content across two machines' working directories.



    The most basic is: if you committed changes on machine A, and want them on machine B, you can fetch them from A to B so that A and B will have the patch via the same commit. Sometimes that's not a suitable answer, and so other ways are possible. But which one makes sense for what you're doing depends on what you're doing, and we don't know enough to necessarily address that yet.



    So we can follow up on that if it makes sense, but let's start by clarifying a possible conceptual misunderstanding:




    (in the working directory A) I performed a git pull and expected my local commit to disappear. It did not.




    My question would be, why is that the expected behavior? In general, you don't want your local changes to disappear when you pull in remote changes; instead you want to combine them.



    Now, in the specific case where the local changes and the remote changes are identical, you might indeed want the local changes to go away, and if you rebase the local changes onto the newly-fetched remote changes then that is what should happen.



    git pull --rebase


    Now if, in the process of rebasing your local changes onto the fetched changes, git finds that a local commit's patch is exactly the same as the patch for one of the fetched commits, the local commit will be discarded.



    Perhaps you expected that behavior because in the past you've used repos configured to rebase on pull by default? Be aware that auto-rebasing is documented as a "potentially dangerous" feature, so you might want to consider if it's really the best default; but if it is the default you want, look up pull.rebase in the git config docs: https://git-scm.com/docs/git-config






    share|improve this answer













    There are many ways to look at how you might coordinate the content across two machines' working directories.



    The most basic is: if you committed changes on machine A, and want them on machine B, you can fetch them from A to B so that A and B will have the patch via the same commit. Sometimes that's not a suitable answer, and so other ways are possible. But which one makes sense for what you're doing depends on what you're doing, and we don't know enough to necessarily address that yet.



    So we can follow up on that if it makes sense, but let's start by clarifying a possible conceptual misunderstanding:




    (in the working directory A) I performed a git pull and expected my local commit to disappear. It did not.




    My question would be, why is that the expected behavior? In general, you don't want your local changes to disappear when you pull in remote changes; instead you want to combine them.



    Now, in the specific case where the local changes and the remote changes are identical, you might indeed want the local changes to go away, and if you rebase the local changes onto the newly-fetched remote changes then that is what should happen.



    git pull --rebase


    Now if, in the process of rebasing your local changes onto the fetched changes, git finds that a local commit's patch is exactly the same as the patch for one of the fetched commits, the local commit will be discarded.



    Perhaps you expected that behavior because in the past you've used repos configured to rebase on pull by default? Be aware that auto-rebasing is documented as a "potentially dangerous" feature, so you might want to consider if it's really the best default; but if it is the default you want, look up pull.rebase in the git config docs: https://git-scm.com/docs/git-config







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 13 '18 at 20:47









    Mark AdelsbergerMark Adelsberger

    20.4k11321




    20.4k11321












    • are you saying the answer is the parameter --rebase for git pull?

      – Frank Puck
      Nov 13 '18 at 20:55











    • yes -- I expected this to be merged automatically. One reason for this is, that I cannot imagine multiple unnamed tips of a source code control system. And I was told, that --rebase is only cosmetic to reorder local commits to come after remote commits. The basic problem is, that git is basically undocumented (and also bad designed).

      – Frank Puck
      Nov 13 '18 at 21:05











    • from the man page: "More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase, it runs git rebase instead of git merge."

      – Frank Puck
      Nov 13 '18 at 21:15











    • @FrankPuck - Ok... taking those one at a time. First: No, I am not saying that "the answer" is the parameter --rebase; if I were saying that's the answer, my answer would be quite a lot shorter.

      – Mark Adelsberger
      Nov 14 '18 at 0:43











    • @FrankPuck - Expecting pull to merge automatically - which it does - is not the same as expecting the commit you made to be gone - which would only happen under specific conditions, including that you use the --rebase option. git is neither undocumented in this behavior, nor poorly designed.

      – Mark Adelsberger
      Nov 14 '18 at 0:44

















    • are you saying the answer is the parameter --rebase for git pull?

      – Frank Puck
      Nov 13 '18 at 20:55











    • yes -- I expected this to be merged automatically. One reason for this is, that I cannot imagine multiple unnamed tips of a source code control system. And I was told, that --rebase is only cosmetic to reorder local commits to come after remote commits. The basic problem is, that git is basically undocumented (and also bad designed).

      – Frank Puck
      Nov 13 '18 at 21:05











    • from the man page: "More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase, it runs git rebase instead of git merge."

      – Frank Puck
      Nov 13 '18 at 21:15











    • @FrankPuck - Ok... taking those one at a time. First: No, I am not saying that "the answer" is the parameter --rebase; if I were saying that's the answer, my answer would be quite a lot shorter.

      – Mark Adelsberger
      Nov 14 '18 at 0:43











    • @FrankPuck - Expecting pull to merge automatically - which it does - is not the same as expecting the commit you made to be gone - which would only happen under specific conditions, including that you use the --rebase option. git is neither undocumented in this behavior, nor poorly designed.

      – Mark Adelsberger
      Nov 14 '18 at 0:44
















    are you saying the answer is the parameter --rebase for git pull?

    – Frank Puck
    Nov 13 '18 at 20:55





    are you saying the answer is the parameter --rebase for git pull?

    – Frank Puck
    Nov 13 '18 at 20:55













    yes -- I expected this to be merged automatically. One reason for this is, that I cannot imagine multiple unnamed tips of a source code control system. And I was told, that --rebase is only cosmetic to reorder local commits to come after remote commits. The basic problem is, that git is basically undocumented (and also bad designed).

    – Frank Puck
    Nov 13 '18 at 21:05





    yes -- I expected this to be merged automatically. One reason for this is, that I cannot imagine multiple unnamed tips of a source code control system. And I was told, that --rebase is only cosmetic to reorder local commits to come after remote commits. The basic problem is, that git is basically undocumented (and also bad designed).

    – Frank Puck
    Nov 13 '18 at 21:05













    from the man page: "More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase, it runs git rebase instead of git merge."

    – Frank Puck
    Nov 13 '18 at 21:15





    from the man page: "More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. With --rebase, it runs git rebase instead of git merge."

    – Frank Puck
    Nov 13 '18 at 21:15













    @FrankPuck - Ok... taking those one at a time. First: No, I am not saying that "the answer" is the parameter --rebase; if I were saying that's the answer, my answer would be quite a lot shorter.

    – Mark Adelsberger
    Nov 14 '18 at 0:43





    @FrankPuck - Ok... taking those one at a time. First: No, I am not saying that "the answer" is the parameter --rebase; if I were saying that's the answer, my answer would be quite a lot shorter.

    – Mark Adelsberger
    Nov 14 '18 at 0:43













    @FrankPuck - Expecting pull to merge automatically - which it does - is not the same as expecting the commit you made to be gone - which would only happen under specific conditions, including that you use the --rebase option. git is neither undocumented in this behavior, nor poorly designed.

    – Mark Adelsberger
    Nov 14 '18 at 0:44





    @FrankPuck - Expecting pull to merge automatically - which it does - is not the same as expecting the commit you made to be gone - which would only happen under specific conditions, including that you use the --rebase option. git is neither undocumented in this behavior, nor poorly designed.

    – Mark Adelsberger
    Nov 14 '18 at 0:44











    0














    You can do it with a git pull, but I would use rsync



    cd directory_A; rsync -mauvPAX directory_B/ .


    This would efficiently duplicate the content of directory_B into directory_A and preserve any files in directory_A that are missing from directory_B.



    If you want to scrub any additional files from directory_A that aren't in directory_B then include the --delete flag.






    share|improve this answer



























      0














      You can do it with a git pull, but I would use rsync



      cd directory_A; rsync -mauvPAX directory_B/ .


      This would efficiently duplicate the content of directory_B into directory_A and preserve any files in directory_A that are missing from directory_B.



      If you want to scrub any additional files from directory_A that aren't in directory_B then include the --delete flag.






      share|improve this answer

























        0












        0








        0







        You can do it with a git pull, but I would use rsync



        cd directory_A; rsync -mauvPAX directory_B/ .


        This would efficiently duplicate the content of directory_B into directory_A and preserve any files in directory_A that are missing from directory_B.



        If you want to scrub any additional files from directory_A that aren't in directory_B then include the --delete flag.






        share|improve this answer













        You can do it with a git pull, but I would use rsync



        cd directory_A; rsync -mauvPAX directory_B/ .


        This would efficiently duplicate the content of directory_B into directory_A and preserve any files in directory_A that are missing from directory_B.



        If you want to scrub any additional files from directory_A that aren't in directory_B then include the --delete flag.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 17:18









        Alexx RocheAlexx Roche

        1,9432130




        1,9432130



























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285972%2fhow-to-keep-two-separate-working-directories-in-sync-or-is-git-able-to-recogn%23new-answer', 'question_page');

            );

            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







            這個網誌中的熱門文章

            Barbados

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3