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 used git 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?
question from:
https://stackoverflow.com/questions/65921715/how-merging-works-when-we-use-git-add-filename 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…