Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. why? When creating a branch with git branch, it doesn't work.
Forum Updated to NodeBB v4.3 + New Features

why? When creating a branch with git branch, it doesn't work.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 752 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • lincolnL Offline
    lincolnL Offline
    lincoln
    wrote on last edited by
    #1

    I have the following doubt, when I create a new branch called dev: git branch "dev", and I make changes in this branch, they are also reflected in the main branch, which should not happen, because when changing branches, with git checkout main, there are also the changes I made in my dev branch, could someone give me a suggestion as to why this is happening.

    I leave the screen shot, in case it helps.
    As an example I only entered a comment in my main.cpp file, being in the dev branch, and as I commented above, when I switch to the main branch the comment also appears and indicates that there were changes in the main.cpp file, thanks in advance for your answers.

    23902ccf-c850-429c-891d-b47603d9867c-image.png

    Solitary wolf

    JKSHJ 1 Reply Last reply
    0
    • lincolnL lincoln

      I have the following doubt, when I create a new branch called dev: git branch "dev", and I make changes in this branch, they are also reflected in the main branch, which should not happen, because when changing branches, with git checkout main, there are also the changes I made in my dev branch, could someone give me a suggestion as to why this is happening.

      I leave the screen shot, in case it helps.
      As an example I only entered a comment in my main.cpp file, being in the dev branch, and as I commented above, when I switch to the main branch the comment also appears and indicates that there were changes in the main.cpp file, thanks in advance for your answers.

      23902ccf-c850-429c-891d-b47603d9867c-image.png

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @lincoln said in why? When creating a branch with git branch, it doesn't work.:

      when I create a new branch called dev: git branch "dev", and I make changes in this branch, they are also reflected in the main branch

      You did not make any changes in your "dev" branch. You only made changes in your local copy of the file.

      If you want the changes to become part of the "dev" branch, then you must commit your change when the "dev" branch is checked out.

      After you commit it, then git checkout main will no longer show the change.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      3
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by ChrisW67
        #3

        git branch dev creates a branch but does not switch your working copy to that branch. Follow up with one of git switch dev or git checkout dev.

        You can create a branch and switch your working copy in one action git checkout -b dev

        Edit: Actually @JKSH is closer to answering the particular issue.

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved