Reputation: 951
In my Laravel application I created a packet (located in the workbench directory). Now I'd like to publish it to my private Bitbucket repository so that I can use it in different projects and once it is ready I also like to publish it to GitHub. But I have no idea how to publish only the contents of the new package to a new Bitbucket repo.
Hope somebody can point me in the right direction?
Update based on Kacy Raye suggestions
These are the steps I took. To avoid troubles, I created a new dir and cloned the repo to the dir and pushed the repo to a new repo.
sudo mkdir <application>
sudo chown <user> <application>
git clone [email protected]:<user-name>/<old-repo>.git
git remote set-url origin [email protected]:<user-name>/<new-repo>.git
git push origin master
With the new repo set-up I now want to push the package (src
dir is located in workbench/user-name/package-name/
) to a newly created package repo. These are the steps I took.
git remote add <package-name> [email protected]:<user-name>/<package-name>.git
git checkout -b <package-name>
git rm -r app/ artisan bootstrap/ bower.json composer.json CONTRIBUTING.md phpunit.xml public/ readme.md server.php # all files removed except the workbench dir
git rm -r --cached workbench/ # need only the package
git add workbench/<user-name>/<package-name>/
git commit -m'init'
git push <package-name> master # want the package pushed to the new repo on its master banch
And then all files are pushed to the server, not just the files of my repo (not even as i mentioned before just the workbench dir) :(
Update 2
On the Laravel IRC chat I discussed the problem and found the solution! I just needed to do a git init
in the wordkbench/<vendor>/<package>
dir, add the new remote, git commit, and git push.
Upvotes: 2
Views: 2141
Reputation: 3430
My understanding of the problem is that you have two repos. One with the overall project and one specifically for the package. The goal is that you only want to push the package.
After adding the remote repo specifically for the package, you can switch to a new branch, remove everything you don't want to push from the index (also know as the "staging area"), commit it to your local repo, then push it to the remote repo you want.
git remote add <whateverYouWantToNameTheRemote> <URL the remote is located at>
git checkout -b shinyNewBranch # (-b creates a new branch and switches to it)
git rm <fileYouDontWant1> <fileYouDontWant2> ...
# (Do a 'git add' here if you did not already add the package to the index)
git commit -m "whatever commit message you want"
git push <theNameYouGaveTheRemote> <branchYouWantToPushTo>
Keep in mind that git rm
without the --cached
option wil not only remove files from the index, but it will also remove the files from the working directory. This shouldn't be a problem though so long as you committed the files in the branch you switched from. When you switch back to that branch using git checkout branchName
, whatever files were in your most recent commit for that branch will be loaded into the working directory.
Upvotes: 2