I'm testing and developing in an OpenShift All-in-One cluster in a VM. I needed my local working branch of a git repository cloned in my VM. I compiled bits and pieces of my web search into this post, so hopefully when the next developer searches the title of this blog they'll find this!
Substitute in the commands below:
REPO=repoToClone
WORKING_BRANCH=workingBranchName
BARE_REPO="$REPO-bare"
PATH_TO_REPOS=/path/to/your/repo
REPO_PATH=/path/to/your/repo/$REPO
BARE_REPO_PATH=/path/to/your/repo/$BARE_REPO
PUBLIC_DNS_OF_VM
VM_USER=output of 'echo ${USER}' from VM
Run these commands while ssh'd into the VM. I recommend putting these in a script so you can easily sync your local repositories to your VM whenever necessary:
sudo mkdir -p $PATH_TO_REPOS
sudo chown -R $USER:$USER $PATH_TO_REPOS
cd $PATH_TO_REPOS
git init --bare $BARE_REPO
git clone $BARE_REPO_PATH $REPO_PATH
cd $REPO
touch file.txt && git add . && git commit -m 'added a file so I could create a working branch'
git push origin master
Here is output of the above commands:
In local machine, clone your git repository to the VM $BARE_REPO:
cd $REPO_PATH
git push -q ssh://$VM_USER@$PUBLIC_DNS_OF_VM$BARE_REPO_PATH --force --verbose
Here is output from the git push:
SSH back into VM and run these:
cd $REPO_PATH
git pull (this will open a git vim window, enter 'wq' to continue merge)
git checkout $WORKING_BRANCH
Finally, here is a screenshot of the repository contents and branch name in the VM:
You now have your current local working branch of a git repository cloned to your VM :)
À propos de l'auteur
Plus de résultats similaires
RPM and DNF features and enhancements in Red Hat Enterprise Linux 10.1
From maintenance to enablement: Making your platform a force-multiplier
Bad Bosses | Compiler: Tales From The Database
Rolling with the Punches | Compiler: Tales From The Database
Parcourir par canal
Automatisation
Les dernières nouveautés en matière d'automatisation informatique pour les technologies, les équipes et les environnements
Intelligence artificielle
Actualité sur les plateformes qui permettent aux clients d'exécuter des charges de travail d'IA sur tout type d'environnement
Cloud hybride ouvert
Découvrez comment créer un avenir flexible grâce au cloud hybride
Sécurité
Les dernières actualités sur la façon dont nous réduisons les risques dans tous les environnements et technologies
Edge computing
Actualité sur les plateformes qui simplifient les opérations en périphérie
Infrastructure
Les dernières nouveautés sur la plateforme Linux d'entreprise leader au monde
Applications
À l’intérieur de nos solutions aux défis d’application les plus difficiles
Virtualisation
L'avenir de la virtualisation d'entreprise pour vos charges de travail sur site ou sur le cloud