Pages

Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Wednesday, July 12, 2023

Script to find the latest Branches on GIT Repository

 For every release we create a release branch for every microservice. few times we miss few microservice and it'll fail the deployment. hence i created this script to find the latest release branch on each repository to ensure for a smooth deployment.

1. We need to create reference file with GIT remote URL. we can copy the clone SSH git from each repo and generate this file

>> cat branch.txt

git@github.abc.com:DSC/a-frontend.git

git@github.abc.com:DSC/b-service.git

git@github.abc.com:DSC/c-portal.git

git@github.abc.com:DSC/d-service.git

git@github.abc.com:DSC/e-service.git

git@github.abc.com:DSC/f-service.git

git@github.abc.com:DSC/g-service.git

git@github.abc.com:DSC/h-service.git

git@github.abc.com:DSC/i-service.git

git@github.abc.com:DSC/j-service.git


2. We need to create the script,

>>vi find_branch.sh


#!/bin/bash

# Script to pull the GIT Repositories and find the latest branch"


echo -e "       Summary    " > latest.txt

echo -e "-------------------" >> latest.txt


for i in `cat branch.txt`;

  do

   j=`echo $i | cut -d/ -f2 | cut -d. -f1`

   echo "###################################"

   echo "Sync the $j Git Repository"

   echo "###################################"

   #`git clone $i --recurse-submodules`

   cd $j

   git pull --recurse-submodules

   git branch -r --sort=-committerdate | grep release | head -2

   echo "$j = `git branch -r --sort=-committerdate | grep release | head -1`" >> ../latest.txt

   cd ../

   echo -e "###################################\n\n"

done


cat latest.txt


3. Execute the create the script,

>>./find_branch.sh


Saturday, January 21, 2023

Git Push & Pull Submodules

# To pull the Git branch along with submodules 

git clone --recurse-submodules <Repo URL>

for eg) 

git clone --recurse-submodules StruxureWareCloud@URL/StruxureWareCloud/Exchange/exst_infra


# To change / switch the branch

git branch

git checkout <new branch>


# To branch out to new branch

git remote -v

git checkout -b Feature/Blah_Blah develop


# To push to Git Branch

git push --set-upstream origin Feature/Listener_rule_frontend


git push -u origin