I have a project in existing repository, the folder structure :
myproject (master)
+-- app/ (master)
+-- dist/ (in .gitignore, but i need it as other branch)
+-- node_modules (.gitignore)
+-- index.html (master)
+-- gulpfile.babel.js (master)
+-- package.json (master)
Is there a way to push dist
to a separate branch of the same repository?
To clarify, I want only dist
files in the deploy
branch, and keep the another files in the master
.
In order to push your branch to another remote branch, use the “git push” command and specify the remote name, the name of your local branch as the name of the remote branch.
Is there a way to push
dist
to a separate branch of the same repository?
There is, using git submodule
.
deploy
'dist
folder content in the empty repo, add and commit, and push.dist
folder submodule.That is:
git checkout --orphan deploy
# copy your folder content
git add .
git commit -m "deploybranch folder content"
git push -u origin deploy
Then
git checkout master
git submodule add -b deploy -- /remote/url/of/your/own/repo dist
git commit -m "Add deploy branch as submodule"
git push
In your master
branch, you will keep a reference to deploy
through the dist
root folder submodule.
That being said, keep in mind what is generated and deployed is usually not stored in a source control file system, but in a binary referential like Nexus or Artifactory: make sure you don't keep huge binaries in there.
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