Assume this is my project structure:
- project
- .git
- scr
- component
- file.js
- I did clone the project
- Made a new branch by
git checkout -b "newBranch"
- Made some changes on
file.js
- Added it to the stage by
git add /scr/compoent/file.js
- Then committed it by
git commit -m "some changes"
- Finally pushed it on the server by
git push origin newBranch
From the beginning of my life until now, I only was using
git add .
for adding changes to the stage. Few mins ago, for the first time, I usedgit add file.js
instead.
After those commands, I went to the GitLab interface -> Repasitory -> File -> newBranch
and I saw ONLY file.js
there. Also, made a merge request by clicking on create merge request
, then assigned it to me (myself) and put master
as the destination branch. After merging, the project structure turned out like this:
- project
- .git
- file.js //=> The file contains the changes
- scr
- component
- file.js //=> This file remained untouched
My question is, why file.js
is pasted in the root of the project? How can we apply changes on the real file in such cases instead of creating an instance file (containing changes) and locate it on the root?