• AVR Freaks

Hot!Files with erros when I switch from one branch to another branch

Author
vra
Junior Member
  • Total Posts : 93
  • Reward points : 0
  • Joined: 2014/07/14 18:35:19
  • Location: 0
  • Status: offline
2019/08/17 10:35:47 (permalink)
0

Files with erros when I switch from one branch to another branch

Hi all, how are you?. I have three branches in my program, one for I/O, one for oscillator and the master branch, and when I try to switch from the one for the oscillator to the I/O branch the files of the project seems to loose sincronization, the icons of the header files on the project tree appears in white with an exclamation mark and the icons for source files appears in whit but without the exclamation mark.
 
When I try to refresh them it doesn't do anything and I need to go back to the osscillator branch to been able to refresh the files again.
 
What is happening?.
#1

19 Replies Related Threads

    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3233
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/17 10:41:13 (permalink)
    0
    What are, "branches" you speak of ?  Do you mean files ?
     
    Exclamation Mark on files normally mean that the file can not be found, may have been renamed or moved.

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #2
    vra
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/17 10:57:19 (permalink)
    0
    Gort2015
    What are, "branches" you speak of ?  Do you mean files ?
     
    Exclamation Mark on files normally mean that the file can not be found, may have been renamed or moved.


    The image below shows the repository browser, you can see the three local branches
     


    and in the following image you can see my project tree
     

     
    if I swithc from the branch Reloj to the branch E_S the project tree starts to see it like the following image
     

     
    then when I try to refreshe those files from my current branch (E_S) nothing happen, I need to go back to the "Reloj branch to be capable of refresh those files.
     
    #3
    vra
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/17 11:03:50 (permalink)
    0
    May be I'm mussinderstanding git but I think I should see all my files on al my branches even if I switch between them
    #4
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3233
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/17 16:13:28 (permalink)
    0
    Should have mentioned git in the first post.

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #5
    vra
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/17 17:57:01 (permalink)
    0
    Gort2015
    Should have mentioned git in the first post.


    Sorry for that but is the first time that it happens to me
    #6
    TJvV
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2014/05/21 01:27:05
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/19 00:09:13 (permalink)
    0
    Hi,
     
    It is my personal experience that when switching branches/commits with git, the project configuration is not always updated/reloaded properly.
    To remedy this, I always close MPLAB or the project before doing such a switch.
     
    It's also worth noting that not all changes to the project files may have been saved when making a commit, which can in turn cause a lot of headaches (and missing files).
    Make sure when committing that the contents in nbproject/configurations.xml are actually set to the state you want.
    If they are not, either use File->Save All (Ctrl+Shift+S), or just close MPLAB.
     
    #7
    moser
    Super Member
    • Total Posts : 504
    • Reward points : 0
    • Joined: 2015/06/16 02:53:47
    • Location: Germany
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/19 01:22:16 (permalink)
    0
    I agree with TJvV. It doesn't really matter if you try to switch the branch inside MPLAB X or with an external tool, because at some point MPLAB X always gets confused if the project is still open.
     
    In general, if you switch between branches:
    - Close the project.
    - Switch the branch.
    - Open the project again.
    When you switch your branch, closing the project is enough according to my experience, and you do not need to close MPLAB X. However, if you look at the memory consumption of MPLAB X, this is a pretty good reason to also restart MPLAB X, and that is why I usually restart it, too.
     
    If your branches are VERY VERY similar, you can risk switching the branch without closing the project. But if you have added/deleted/renamed files in your branches or changed something in the project configuration or used MHC, then don't even try it.
     
    Anyway, after switching a branch never just do a "Build Project". Always do "Clean" or "Clean and Build Project".
     
    Also make sure your repository follows the recommendations by setting your .gitignore file accordingly:
    "Which files in an MPLAB® X Project should be under version control?" ( https://microchipdeveloper.com/faq:72 )
    #8
    vra
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/19 11:04:17 (permalink)
    0
    moser
    I agree with TJvV. It doesn't really matter if you try to switch the branch inside MPLAB X or with an external tool, because at some point MPLAB X always gets confused if the project is still open.
     
    In general, if you switch between branches:
    - Close the project.
    - Switch the branch.
    - Open the project again.
    When you switch your branch, closing the project is enough according to my experience, and you do not need to close MPLAB X. However, if you look at the memory consumption of MPLAB X, this is a pretty good reason to also restart MPLAB X, and that is why I usually restart it, too.
     
    If your branches are VERY VERY similar, you can risk switching the branch without closing the project. But if you have added/deleted/renamed files in your branches or changed something in the project configuration or used MHC, then don't even try it.
     
    Anyway, after switching a branch never just do a "Build Project". Always do "Clean" or "Clean and Build Project".
     
    Also make sure your repository follows the recommendations by setting your .gitignore file accordingly:
    "Which files in an MPLAB® X Project should be under version control?" ( https://microchipdeveloper.com/faq:72 )



    Thanks, for now I've apparently solved the problem by doing it the hard way, I mean, by unninstalling and reinstalling again.
    #9
    vra
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/19 11:40:57 (permalink)
    0
    Errata: Forgot it about my last afirmation, the problem still appears, all was working well and when I've switched from the E_S branch to the master branch by using menu git>switch to branch>master then the icons of the files dessapeared and appeared a folder icon that says mplab_platform.
     
    Finally I tried to add those files but the IDE says that the files are already in the project but I can't see them.
    #10
    vra
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/19 16:01:49 (permalink)
    0
    Well, right now I'm very very lost here, I can't imagine why in the life if I switch from a secondary branch to the master branch then I can't see the files created on the secondary branch even if firts I do a merge, then if I go back to the secondary branch then I can recover those files by refreshing them.
     
    I really need help with this.
    #11
    TJvV
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2014/05/21 01:27:05
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/20 00:08:06 (permalink)
    +4 (4)
    Let's go with a simple scenario consisting of two branches and two files:
     
    1. You create a new project and add it to git (master branch)
    2. In the master branch you add a new file (main.c)
    3. You create a commit in the master branch with the files from steps 1. and 2.
    4. Create a new branch (test)
    5. Create a new file (test.c)
    6. Create a commit in the test branch containing test.c and the changes to configurations.xml
     
    7. Switching to master
    Now if you change to the master branch without closing the project, you will be back where you were in step 3 and test.c won't exist, however you may still see the configuration from step 6, which contains a reference to test.c.
    If you now close the project, it will save the configuration and thereby overwrite the configuration you intended to have in step 3.
    In this case, you have a project that references main.c and test.c, even though only main.c exists.
     
    If you closed the project in between the switching, you should end up with the situation in step 3, where you have a project that only references main.c.
     
    8. If you now do a git merge of branch test into branch master, you apply the changes in the test branch to your master branch and you should end up with your master branch in the same situation as step 6: a project that has both main.c and test.c.
     
    I hope this makes it a little more clear.
     
    #12
    GeorgePauley
    Moderator
    • Total Posts : 1153
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/20 11:20:43 (permalink)
    +1 (1)
    I think TJvV explained this pretty clearly.  I just want to add that this is exactly the way the Git plug-in works in NetBeans native (ie, before we turn it into MPLAB X).  So I suspect this is correct behavior.
    #13
    vra
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/20 13:58:29 (permalink)
    0
    TJvV
    Let's go with a simple scenario consisting of two branches and two files:
     
    1. You create a new project and add it to git (master branch)
    2. In the master branch you add a new file (main.c)
    3. You create a commit in the master branch with the files from steps 1. and 2.
    4. Create a new branch (test)
    5. Create a new file (test.c)
    6. Create a commit in the test branch containing test.c and the changes to configurations.xml
     
    7. Switching to master
    Now if you change to the master branch without closing the project, you will be back where you were in step 3 and test.c won't exist, however you may still see the configuration from step 6, which contains a reference to test.c.
    If you now close the project, it will save the configuration and thereby overwrite the configuration you intended to have in step 3.
    In this case, you have a project that references main.c and test.c, even though only main.c exists.
     
    If you closed the project in between the switching, you should end up with the situation in step 3, where you have a project that only references main.c.
     
    8. If you now do a git merge of branch test into branch master, you apply the changes in the test branch to your master branch and you should end up with your master branch in the same situation as step 6: a project that has both main.c and test.c.
     
    I hope this makes it a little more clear.
     




    Thanks @TJvV, @Gort2015, @moser and @GeorgePauley, initially when I've made the post I was switching between branches without a merge wath was wrong, after solved that I couldn't understand why I needed to close the project but now I know that it is the normal behavior of netbeans.
     
    Then and from now I've closed the project after doing the merge, I've reopened and only after reopened I've switched branchs and I'm looking all my files where there supose to be.
    #14
    vra
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/20 16:52:38 (permalink)
    0
    Just one last question, its normal to work in such a way?, I mean, by creating a branch and changing to a branch where one can't see the content of another branch unless one need it?.
    #15
    moser
    Super Member
    • Total Posts : 504
    • Reward points : 0
    • Joined: 2015/06/16 02:53:47
    • Location: Germany
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/21 06:15:21 (permalink)
    0
    To my understanding, yes. However, you have several possibilities to deal with this.
     
    For a single file you can select in MPLAB X "Team > Diff > Diff to ..." and then select a local branch. You will get a diff window in MPLAB X.
     
    And of course, if the branch which you want to have a look at, is not a real branch but just an old state of your current branch, then you can also use the history function in MPLAB X. Unfortunately the other git branches are not listed in this history.
     
    Another way is to use external tools. For example with TortoiseGit you can open the "Git Show log" window directly from the context menu of the Windows Explorer. You can set this window to show all branches and commits. Then you simply select two commits with CTRL+left mouse button, and then select "Compare revisions" from the context menu. Or you select one commit and "Compare with working tree". You get a list of all changed files, which you can just click to get a diff window. If you don't like their diff tool I think you can replace it in the settings. Personally, I like the "Git Show log" window very much and I work a lot with it.
     
    Another way is to just clone/copy the project folder with the repository and keep the copy up to date by fetching from the main version. By doing this, you have two folders which you can set to separate branches. And then you can open or compare the files. You can just open the files from both copies in MPLAB X and then even do a "diff" in MPLAB X directly. Or you can diff it with external tools. There are some nice tools which can diff complete folder structures and can present the results clearly.
     
    And I think there are even more ways which allow you to keep an overview about multiple branches.
    #16
    vra
    Junior Member
    • Total Posts : 93
    • Reward points : 0
    • Joined: 2014/07/14 18:35:19
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/08/21 09:10:49 (permalink)
    0
    moser
    To my understanding, yes. However, you have several possibilities to deal with this.
     
    For a single file you can select in MPLAB X "Team > Diff > Diff to ..." and then select a local branch. You will get a diff window in MPLAB X.
     
    And of course, if the branch which you want to have a look at, is not a real branch but just an old state of your current branch, then you can also use the history function in MPLAB X. Unfortunately the other git branches are not listed in this history.
     
    Another way is to use external tools. For example with TortoiseGit you can open the "Git Show log" window directly from the context menu of the Windows Explorer. You can set this window to show all branches and commits. Then you simply select two commits with CTRL+left mouse button, and then select "Compare revisions" from the context menu. Or you select one commit and "Compare with working tree". You get a list of all changed files, which you can just click to get a diff window. If you don't like their diff tool I think you can replace it in the settings. Personally, I like the "Git Show log" window very much and I work a lot with it.
     
    Another way is to just clone/copy the project folder with the repository and keep the copy up to date by fetching from the main version. By doing this, you have two folders which you can set to separate branches. And then you can open or compare the files. You can just open the files from both copies in MPLAB X and then even do a "diff" in MPLAB X directly. Or you can diff it with external tools. There are some nice tools which can diff complete folder structures and can present the results clearly.
     
    And I think there are even more ways which allow you to keep an overview about multiple branches.


    Well, thank you @moser for the explanation.
    #17
    jdunne525
    Junior Member
    • Total Posts : 36
    • Reward points : 0
    • Joined: 2006/04/28 10:54:28
    • Location: 0
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/09/06 10:47:17 (permalink)
    0
    We've been dealing with this for years.  It is ridiculous that we can't get this fixed.  This should be such a simple thing for MPLAB X to scan the configurations.xml file and recognize that the file date/time has changed and reload the project.  I don't want to use the built-in git integration.
     
    I tried a couple years ago to create a support ticket and was basically told "that's the way it works".  Please somebody push Microchip to fix this.
    #18
    Jim Nickerson
    User 452
    • Total Posts : 6187
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/09/06 11:43:21 (permalink)
    0
    I wonder if this might be a netbeans issue ?
    #19
    moser
    Super Member
    • Total Posts : 504
    • Reward points : 0
    • Joined: 2015/06/16 02:53:47
    • Location: Germany
    • Status: offline
    Re: Files with erros when I switch from one branch to another branch 2019/09/09 01:34:22 (permalink)
    0
    I think, some time ago, I have read in another thread that it is in fact a NetBeans issue. There are Plugins for Git, Mercurial and Subversion. And those plugins were not changed in any way for MPLAB X.
    #20
    Jump to:
    © 2019 APG vNext Commercial Version 4.5