I have two repositories namely A
and B
. By mistake I cloned repo B inside A on my machine. I removed all the code from the repo B but when I pushed and merged my code from A on origin, it also shows a subproject commit B
on Github repo.
I want to remove the subproject commit from my master on origin. Will these steps work?
1. rmdir B (on my local repo A)
2. Pushing my repo A to origin
3. Merging
Just run the rm command with the -f and -r switch to recursively remove the . git folder and all of the files and folders it contains. This Git repo remove command also allows you to delete the Git repo while allowing all of the other files and folder to remain untouched.
If you have modified, added and committed changes to a file, and want to undo those changes, then you can again use git reset HEAD~ to undo your commit. Similar to the previous example, when you use git reset the modifications will be unstaged.
A submodule commit is a gitlink, special entry recorded in the index, created when you add a submodule to your repo; It records the SHA1 currently referenced by the parent repo. A git submodule update --init is enough to populate the laravel subdirectory in your repo.
Since GitHub displays B as a gray folder within A repo, that means B has been added to A as a submodule.
That gray folder is a gitlink, a special entry in the index.
See "How do I remove a Git submodule?":
Locally, do git submodule deinit asubmodule
and git rm B
(B
without any trailing slash B/
).
Then push to GitHub, and B
should be gone.
Assuming you want to remove commit which shown in diff like
-Subproject commit <old commit hash>
+Subproject commit <new commit hash>
go to submodule directory, than
git checkout <old commit hash>
return back to main project:
git add .
git commit --amend --no-edit
git push
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