Last active
September 9, 2021 06:52
-
-
Save Keiku/063f72cc0d84b1a9bbf7f1ff9ed2d018 to your computer and use it in GitHub Desktop.
Reflect changes in the original repository in the mirror repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I refer to "git --How do I update my bare repo? --Stack Overflow https://stackoverflow.com/questions/3382679/how-do-i-update-my-bare-repo" | |
# Create mirror repository | |
git clone --bare https://github.com/Keiku/test1.git | |
cd test1.git | |
git push --mirror https://github.com/Keiku/test2.git | |
# Promote development with mirror repository | |
cd ../ | |
git clone https://github.com/Keiku/test2.git | |
cd test2 | |
git checkout -b develop | |
touch test2-1.txt | |
git add test2-1.txt | |
git commit -m 'add test2-1.txt' | |
git push origin develop | |
git checkout main | |
# Update original repository | |
cd ../ | |
git clone https://github.com/Keiku/test1.git | |
cd test1 | |
touch test1-1.txt | |
git add test1-1.txt | |
git commit -m 'add test1-1.txt' | |
git push origin main | |
# 1st time: Reflect changes in the original repository in the mirror repository | |
cd ../test2 | |
git remote add remote_site https://github.com/Keiku/test1.git | |
git fetch -u remote_site '+refs/heads/*:refs/heads/*' | |
git fetch -u remote_site '+refs/tags/*:refs/tags/*' | |
git push --mirror | |
git reset --hard origin/main | |
# Update original repository | |
cd ../test1 | |
touch test1-2.txt | |
git add test1-2.txt | |
git commit -m 'add test1-2.txt' | |
git push origin main | |
# 2nd time: Reflect changes in the original repository in the mirror repository | |
cd ../test2 | |
git fetch -u remote_site '+refs/heads/*:refs/heads/*' | |
git fetch -u remote_site '+refs/tags/*:refs/tags/*' | |
git push --mirror | |
git reset --hard origin/main | |
# Reflect changes in main in develop | |
git checkout develop | |
git merge origin main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment