I don't find, how I can quick add, commit and push changes to 2 GitHub repositories both, that I don't need add, commit and push change to 2 GitHub repositories separately each time.
Local workspace:
SashaSource
.git
SashaSourceSubfolder1
SashaSourceSubfolder2
SashaOutput.github.io
.git
index.html
SashaAnother.html
I have 2 remote GitHub repositories:
SashaSource
— for SashaSource
local directory;SashaOutput.github.io
— for SashaOutput.github.io
local directory, location of my GitHub Pages site.I use Pelican static site generator. I make a changes in SashaSourceSubfolder1
or SashaSourceSubfolder2 folder
→ I make a build (use make
, fabric
tools or pelican content
command) → I get output in SashaOutput.github.io
folder. (I set Pelican, that SashaOutput.github.io/.git
folder don't change, if I make a build).
Now I want to push my changes to SashaSource
and SashaOutput.github.io
remote repositories.
I need to run
git add . && git commit -m "Example commit description" && git push
in SashaSource
repository than I need to run same command to SashaOutput.github.io
repository.
I print in terminal any command → git push changes to SashaSource
and SashaOutput.github.io
remote repositories both with a same commit description, that user don't need to run same command 2 times each time.
I find, how I can push changes to 2 remote repositories. I set git remote
→ git add . && git commit -m "Example commit description"
→ I get output:
D:\SashaSource\>git push all
To https://github.com/Kristinita/SashaOutput.github.io.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/Kristinita/SashaOutput.github.io.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull …') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 770 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To https://github.com/Kristinita/SashaSource
dc36727..3e5d63b master -> master
My changes push to 1 remote repository. I think, that I need add and commit changes to SashaOutput.github.io
before push, but I don't find, how I can do it.
I read another Stack Overflow questions about push to 2 or more repositories, but I don't find in it, how user can add and commit changes to 2 repositories both.
I don't understand, how I can to write script for expected behavior in my Windows. Commit description — is a variable, how I can use it in script?
SashaOutput.github.io
, because GitHub Pages don't support source for Pelican and needs to be output directory in root of repository. Please, do not offer use 1 remote GitHub repository for my site, not 2.Operating system and version:
Windows 10 Enterprise LTSB 64-bit EN
git:
version 2.12.0.windows.1
Solution for Windows users.
Script in section 3 add, commit and push changes to remote source repository (SashaSource
in question), then add, commit and push changes to remote output repository (SashaOutput.github.io
in question). For commit message for both repositories will set variable (%SASHAMESSAGE%
in answer).
Print in your preferred terminal:
SET SASHAMESSAGE=[Test] Sasha Princess of the Universe!
SASHAMESSAGE
— variable for commit message;[Test] Sasha Princess of the Universe!
— example commit message.Create file with bat
extension, for example, GitPush2Repositories.bat
:
git add .
git commit -m "%SASHAMESSAGE%"
git push
cd SashaOutput.github.io
git add .
git commit -m "%SASHAMESSAGE%"
git push
SashaOutput.github.io
— your output folder.Open terminal in your source folder (SashaSource
in a question) → print in terminal:
"D:\SashaBatch\GitPush2Repositories.bat"
D:\SashaBatch\GitPush2Repositories.bat
— path to your bat
file.You must get expected behavior.