Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing subproject commit from github

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

like image 678
Hellboy Avatar asked May 16 '15 12:05

Hellboy


People also ask

How do I remove a .git from a folder?

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.

How do I discard the modified content in git?

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.

What is a subproject commit?

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.


2 Answers

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.

like image 137
VonC Avatar answered Oct 17 '22 08:10

VonC


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
like image 44
Serge S Avatar answered Oct 17 '22 07:10

Serge S