I have a bitbucket repository, with the following structure :
Directory-A->
directory a
directory b
file a
file b
file c
Now I want to move file "b" and file "c" to "directory a"
When I do it on local machine and commit this by git add. I get file b and file c in directory a but they still exists outside it.
When I do it on local machine and commit this by git add. I get file b and file c in directory a but they still exists outside it.
That is because you did a git add .
in directory a
instead of a git add -A .
in Directory-A
.
First, you need to be in Directory-A
(the root one) when you do the git add -A .
(which is a git add -u
+ git add .
) from the root folder:
Directory-A-> <====== there: git add -A .
directory a
file b
file c
directory b
file a
A 'git add -A .
' in Directory-A
will detect the deletion of those files in Directory-A
and their addition in directory a
.
See more at "Difference between “git add -A
” and “git add .
”":
Here is a better alternative. Try the following:
git mv "file b" "file c" "directory a"
Followed by:
git commit -am "hey I moved filed"
Note: I've only used the -am
flag for demonstration purposes. It is not a good practice. You should commit only files with related changes together which makes your repository maintainable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With