proper way to branch using git

So I created a new branch off master called branch-a and then switched to it. I made some modifications, switched back to master to make sure that no changes have been made since, but I see all of my modifications that were made in branch-a in the master branch. Is this right? I would expect master to not have any modifications if I made all my mods in branch-a without merging yet. Here’s what I did:

Started with a clean, up-to-date master branch.

  • git: merge branch and use meaningful merge commit message?
  • commit count calculation in git-describe
  • What to do when parent of branch was squashed?
  • Prevent merging a file from master with Git
  • git workflow for keeping custom-modified open source software up to date?
  • Where to store differences between dev and production branch in git?
    1. git branch -b branch-a
    2. make modifications
    3. git checkout master
    4. git status
    5. I see all the modifications that I made in branch-a

    Is this correct? Is it because I didn’t commit branch-a before switching to master?

  • Testing numpy python libraries from multiple git development branches
  • Git list : viewing git repositories in home folder
  • GitLab bare repository import
  • Accidentally did a branch origin set up to track local branch
  • In git, how can I create an 'isolate branch' (act just the same as master branch)?
  • git Permission denied (publickey)
  • 2 Solutions collect form web for “proper way to branch using git”

    I guess there is a step missing between 2. and 3.:

    2a. add and commit the changes:

    git add -A
    git commit -m "describe your changes" 

    First command adds all changed files to the index,the
    second command commits everything inside the index.

    Now you can switch back to master

    EDIT: checking out a branch changes the repository your changes would be commited to (and syncs unchanged files in the working directory with the HEAD of the branch). Uncommited changes remain in the working directory, added changes remain in the index. No merging takes place until you say so. If this does not clarify things, take a look at the opening part of this article for a great explanation of git trees

    Using git branch separates the action of creating a branch from actually switching to it. Also, you need to commit changes before they exist on a branch.

    git branch -b branch-a

    This creates a branch named branch-a, but does not check it out, so you are still on master. If you want to work on branch-a, you need to do a git checkout branch-a here, or replace the above command with git checkout -b branch-a master.

    make modifications

    Assuming you are on the branch you want to be on, git add <modified files>; git commit at this point will actually create a new commit on the branch containing those changes.

    git checkout master

    You were already on master, so this probably doesn’t do much. git attempts to not lose uncommitted changes, so your working directory should still look the same as before you
    ran git checkout.

    git status

    Should report that you are on master and list the uncommitted changes you have made.

    I see all the modifications that I made in branch-a

    You see all the modifications you made, but you did not make them in branch-a.

    Git Baby is a git and github fan, let's start git clone.