I have a parent repository having branches master stage & develop along with child repository say as submodule which has same branches master stage & develop, I made commits in stage branch in child repository(submodule) and try to push the changes to stage branch in parent repository but still the changes are not reflecting in the GitHub.
note:- Its working for parent repo's master to child repo's master .
**script used for master
**
#!/bin/bash
git init
git clone --recurse-submodules https://github.com/username/file.git
cd file
git submodule update --remote
git commit -a -m "commit in both submodule"
git push -u origin
above script work for for parent repo's master to child repo's master like wise
I want for parent repo's stage to child repo's stage as well.
**I even tried using multiple commands :- git push -u origin stage git config push.default current git config push.default upstream
none of them were working **
CodePudding user response:
Well I prepared a script that works fine for branch to branch commits/push
################ STAGE
#########################################
#!/bin/bash
#git init
git init
#git clone repo stage including submodules
git clone -b stage --recurse-submodules [email protected]:orgs/file.git
#change directory -repo
cd file
#update the remote ie tag/commits
git submodule update --remote
#add commit
git commit -a -m "commit in stage submodules"
#git push
git push -u origin stage
CodePudding user response:
git init git clone means you are cloning a nested Git repository (and its potntial submodules) inside a new local Git repository.
I would not recommend that approach.
Simply:
clone your repository directly at the right branch as you do:
git clone -b stage --recurse-submodules [email protected]:orgs/file.git cd file git submodule update --remoteThen go inside the submodule you need from the parent repository file
cd aSubmodule (check your `file/.gitmodules` file for the list of submodules you currently have) git switch stage # work, add, commit pushThen go back to your main parent repository named 'file', and record the new submodule state
cd .. # add, commit and push
