Adding new branch to git for Urgent Task

Having o lot of modified file in development on my local OS I need to make urgent
modifications of some files and upload them to server. I do

  1. Check that I have many modified files on master
git status
    On branch master
    ... With many modified files
  1. I create new branch and make it active:
git branch dev_1_UrgentTask
git checkout dev_1_UrgentTask
     git branch
    * dev_1_UrgentTask  // Current
  1. I modified 2 files, which I need to upload to git but when I run command
$ git status 
    On branch dev_1_UrgentTask
    Changes not staged for commit:
      ... // I see many uncomitted files I had priorly on step 1)
  1. The thing is that I expected to see only 2 files I modified on step 3) which I have to add and commit in dev_1_UrgentTask branch.
    Did I miss some steps?


Right, so when you branched the repo, it branched it from the master branch. At that point, master and dev_1_UrgentTask are identical - and neither one has your modified files in them.

You made more modifications.

Git is now telling you you need to Add your file modifications to a Commit, and then commit that commit, so that it will update the repo.

You see all those modified files because the branch’s contents match the master’s - and all of those files are different from the master.

1 Like

Had I to run
git stash
before I created dev_1_UrgentTask branch?

That would have worked, yes.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.