Why are files already staged, committed and pushed showing again as untracked, unstaged, or not committed?












0















I am relatively new to git and I have a question re this flow. Below, I switch to develop branch and sync it with remote develop branch. Then I create my-feature branch, modify it in some way, stage, commit and push to remote:





  1. git checkout develop //switch to local develop branch


  2. git pull origin develop (or git fetch origin / git merge origin/develop) //sync local develop with remote develop branch


  3. git checkout -b my-feature //create new branch and switch to it, now I know it contains latest code from remote

  4. Add and modify some files while on my-feature branch


  5. git add . //stage all files I modified


  6. git commit -m "message" //commit all staged files


  7. git status says "nothing to commit, working tree clean"


  8. git push -u origin my-feature //push to remote with tracking option


  9. git status says "Your branch is up to date with 'origin/my-feature"


At this point, I am not done with my-feature. I still have work to do but I will do it in couple of days.



So, couple of days later, I want to continue on my-feature branch but I first want to make sure that my local develop and local my-feature branches are uptodate so I know that any merged pull request by other developers are now present in my local develop and my local my-feature branches so I reduce chance of possible conflicts.



So, I do following to make sure they are updated





  1. git checkout develop //switch to local develop branch


  2. git pull origin develop (or git fetch origin / git merge origin/develop) //bring latest merged code from remote develop to local develop branch


  3. git checkout my-feature //switch to my-feature branch to continue work on it. This shows "Your branch is up to date with 'origin/my-feature'"


To my understanding, I should now merge my updated local develop branch with my local my-feature branch by issuing git merge develop. This will merge develop with branch I am currently on which is my-feature branch. So, any merged pull requests from other developers at remote develop branch should be now integrated into my-feature branch and I can continue work on it knowing that I have latest remote changes. Doing this daily reduces chance of conflicts.



However, before doing so, I issue git status to see the status of my current branch which is my-feature branch.



What I find confusing is that I see some files I added or modified in step 4 above are now reported by git status as 'deleted' > 'to be committed', some as 'modified' > 'not staged', and some as 'untracked' files. Even more confusing is that when I switched to my-feature branch above in step 3, it shows "Your branch is up to date with 'origin/my-feature'", yet the files are showing are either not staged, or not committed, or not tracked.



Is this how it should be?



Should I now simply do git add and git commit again and if so why do I need to do it again if I already did it in steps 6 and 7 above?



Please provide some explanation, I am new to git and find it still confusing. I am familiar only with the commands I described above.










share|improve this question





























    0















    I am relatively new to git and I have a question re this flow. Below, I switch to develop branch and sync it with remote develop branch. Then I create my-feature branch, modify it in some way, stage, commit and push to remote:





    1. git checkout develop //switch to local develop branch


    2. git pull origin develop (or git fetch origin / git merge origin/develop) //sync local develop with remote develop branch


    3. git checkout -b my-feature //create new branch and switch to it, now I know it contains latest code from remote

    4. Add and modify some files while on my-feature branch


    5. git add . //stage all files I modified


    6. git commit -m "message" //commit all staged files


    7. git status says "nothing to commit, working tree clean"


    8. git push -u origin my-feature //push to remote with tracking option


    9. git status says "Your branch is up to date with 'origin/my-feature"


    At this point, I am not done with my-feature. I still have work to do but I will do it in couple of days.



    So, couple of days later, I want to continue on my-feature branch but I first want to make sure that my local develop and local my-feature branches are uptodate so I know that any merged pull request by other developers are now present in my local develop and my local my-feature branches so I reduce chance of possible conflicts.



    So, I do following to make sure they are updated





    1. git checkout develop //switch to local develop branch


    2. git pull origin develop (or git fetch origin / git merge origin/develop) //bring latest merged code from remote develop to local develop branch


    3. git checkout my-feature //switch to my-feature branch to continue work on it. This shows "Your branch is up to date with 'origin/my-feature'"


    To my understanding, I should now merge my updated local develop branch with my local my-feature branch by issuing git merge develop. This will merge develop with branch I am currently on which is my-feature branch. So, any merged pull requests from other developers at remote develop branch should be now integrated into my-feature branch and I can continue work on it knowing that I have latest remote changes. Doing this daily reduces chance of conflicts.



    However, before doing so, I issue git status to see the status of my current branch which is my-feature branch.



    What I find confusing is that I see some files I added or modified in step 4 above are now reported by git status as 'deleted' > 'to be committed', some as 'modified' > 'not staged', and some as 'untracked' files. Even more confusing is that when I switched to my-feature branch above in step 3, it shows "Your branch is up to date with 'origin/my-feature'", yet the files are showing are either not staged, or not committed, or not tracked.



    Is this how it should be?



    Should I now simply do git add and git commit again and if so why do I need to do it again if I already did it in steps 6 and 7 above?



    Please provide some explanation, I am new to git and find it still confusing. I am familiar only with the commands I described above.










    share|improve this question



























      0












      0








      0








      I am relatively new to git and I have a question re this flow. Below, I switch to develop branch and sync it with remote develop branch. Then I create my-feature branch, modify it in some way, stage, commit and push to remote:





      1. git checkout develop //switch to local develop branch


      2. git pull origin develop (or git fetch origin / git merge origin/develop) //sync local develop with remote develop branch


      3. git checkout -b my-feature //create new branch and switch to it, now I know it contains latest code from remote

      4. Add and modify some files while on my-feature branch


      5. git add . //stage all files I modified


      6. git commit -m "message" //commit all staged files


      7. git status says "nothing to commit, working tree clean"


      8. git push -u origin my-feature //push to remote with tracking option


      9. git status says "Your branch is up to date with 'origin/my-feature"


      At this point, I am not done with my-feature. I still have work to do but I will do it in couple of days.



      So, couple of days later, I want to continue on my-feature branch but I first want to make sure that my local develop and local my-feature branches are uptodate so I know that any merged pull request by other developers are now present in my local develop and my local my-feature branches so I reduce chance of possible conflicts.



      So, I do following to make sure they are updated





      1. git checkout develop //switch to local develop branch


      2. git pull origin develop (or git fetch origin / git merge origin/develop) //bring latest merged code from remote develop to local develop branch


      3. git checkout my-feature //switch to my-feature branch to continue work on it. This shows "Your branch is up to date with 'origin/my-feature'"


      To my understanding, I should now merge my updated local develop branch with my local my-feature branch by issuing git merge develop. This will merge develop with branch I am currently on which is my-feature branch. So, any merged pull requests from other developers at remote develop branch should be now integrated into my-feature branch and I can continue work on it knowing that I have latest remote changes. Doing this daily reduces chance of conflicts.



      However, before doing so, I issue git status to see the status of my current branch which is my-feature branch.



      What I find confusing is that I see some files I added or modified in step 4 above are now reported by git status as 'deleted' > 'to be committed', some as 'modified' > 'not staged', and some as 'untracked' files. Even more confusing is that when I switched to my-feature branch above in step 3, it shows "Your branch is up to date with 'origin/my-feature'", yet the files are showing are either not staged, or not committed, or not tracked.



      Is this how it should be?



      Should I now simply do git add and git commit again and if so why do I need to do it again if I already did it in steps 6 and 7 above?



      Please provide some explanation, I am new to git and find it still confusing. I am familiar only with the commands I described above.










      share|improve this question
















      I am relatively new to git and I have a question re this flow. Below, I switch to develop branch and sync it with remote develop branch. Then I create my-feature branch, modify it in some way, stage, commit and push to remote:





      1. git checkout develop //switch to local develop branch


      2. git pull origin develop (or git fetch origin / git merge origin/develop) //sync local develop with remote develop branch


      3. git checkout -b my-feature //create new branch and switch to it, now I know it contains latest code from remote

      4. Add and modify some files while on my-feature branch


      5. git add . //stage all files I modified


      6. git commit -m "message" //commit all staged files


      7. git status says "nothing to commit, working tree clean"


      8. git push -u origin my-feature //push to remote with tracking option


      9. git status says "Your branch is up to date with 'origin/my-feature"


      At this point, I am not done with my-feature. I still have work to do but I will do it in couple of days.



      So, couple of days later, I want to continue on my-feature branch but I first want to make sure that my local develop and local my-feature branches are uptodate so I know that any merged pull request by other developers are now present in my local develop and my local my-feature branches so I reduce chance of possible conflicts.



      So, I do following to make sure they are updated





      1. git checkout develop //switch to local develop branch


      2. git pull origin develop (or git fetch origin / git merge origin/develop) //bring latest merged code from remote develop to local develop branch


      3. git checkout my-feature //switch to my-feature branch to continue work on it. This shows "Your branch is up to date with 'origin/my-feature'"


      To my understanding, I should now merge my updated local develop branch with my local my-feature branch by issuing git merge develop. This will merge develop with branch I am currently on which is my-feature branch. So, any merged pull requests from other developers at remote develop branch should be now integrated into my-feature branch and I can continue work on it knowing that I have latest remote changes. Doing this daily reduces chance of conflicts.



      However, before doing so, I issue git status to see the status of my current branch which is my-feature branch.



      What I find confusing is that I see some files I added or modified in step 4 above are now reported by git status as 'deleted' > 'to be committed', some as 'modified' > 'not staged', and some as 'untracked' files. Even more confusing is that when I switched to my-feature branch above in step 3, it shows "Your branch is up to date with 'origin/my-feature'", yet the files are showing are either not staged, or not committed, or not tracked.



      Is this how it should be?



      Should I now simply do git add and git commit again and if so why do I need to do it again if I already did it in steps 6 and 7 above?



      Please provide some explanation, I am new to git and find it still confusing. I am familiar only with the commands I described above.







      git git-push






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 19:33









      isherwood

      37.2k1082111




      37.2k1082111










      asked Nov 14 '18 at 19:05









      cd491415cd491415

      317110




      317110
























          0






          active

          oldest

          votes











          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%2f53307143%2fwhy-are-files-already-staged-committed-and-pushed-showing-again-as-untracked-u%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f53307143%2fwhy-are-files-already-staged-committed-and-pushed-showing-again-as-untracked-u%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







          Popular posts from this blog

          List item for chat from Array inside array React Native

          Thiostrepton

          Caerphilly