Question

I made few local changes in the master in git repository and released I have to create a new branch. I created a new branch and committed the changes using

git checkout -b changes
git add <files>
git commit -m "new feature in branch"

The name of modified file is "run.pl". Before the new branch, git status on master was

On branch master
Changes not staged for commit
       modified run.pl

Untracked files
       build1.pl

After the new branch, git status in master is

On branch master

Untracked files

   build1.pl

I could not understand how git status on master can change when I committed the changes only to a branch

Was it helpful?

Solution

I made few local changes in the master

That's not actually what you did. You made changes to the files in the directory. Until you commit those changes, they're not "on" any branch, they only exist in the working directory.

The "status" in question is the state of the working directory, compared to the branch that you're currently working on, which was master.

It's not that modifying one branch changes the status in another, it's that you've changed the status of your working directory. When you switched branches, the uncommitted changes stayed put. When you committed those changes to the new branch, they were no longer untracked, so Git no longer has any untracked changes to report to you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top