Posts

DevOps session 13: Automate git SETUP using bash scripting.

Image
  Bash scripting: A Bash Shell Script is a plain text file containing a set of various commands that we usually type in the command line. It is used to automate repetitive tasks on Linux filesystem. It might include a set of commands, or a single command. For example ,to install GIT we need to update the packages, then install git and check if installation is done using Linux commands. We can write all the command in a .sh file and we can execute the file to do all the steps mentioned above. Lets start with example from hello-world. 1.Open terminal and check the root of the bash using below command. CMD: which bash you can see path like  /usr/bin/bash or /bin/bash . 2.Create a hello-world.sh file and paste the below lines. CMD: nano hello-world.sh You can see editor ,add below lines #!/bin/bash # declare MSG variable MSG="Hello World" # print variable on a screen echo $MSG To save the file use CTRL+X, then CTRL+Y and press ENTER 3. To execute the file we need to ad...

DevOps session 12: GIT merging branches/resolving conflicts/tips

Image
  Before starting with GIT merging session, completed previous session on  Git branching  . Let us consider same example from previous session, Developer 1 working on dev-login branch and Developer 2 working on dev-signup branch. In dev-login branch -login.txt file is created and pushed to GitHub In dev-sign branch - signup.txt file is created and pushed to GitHub. In main branch - no files are created Now we want to combine two features login and signup to main branch . To do that GIT providing us merging concept. Follow the below steps to merge the branches: 1. First I want to merge the dev-login branch with main branch . Switch to branch where you want to merge the code from other branch(eg: main in my case). use the below command to merge the code from  dev-login branch to  main branch. You should be on main branch before using below command. CMD: git merge dev-login Once merge is successful. You can check if login.txt is created in main branc...

DevOps session 11: Git branching & best practices

Image
  Let us consider an example your in team where developer 1 working on feature1 , developer2 working on feature 2 etc. With out branching if the developers push and pull the code daily, which will leads to a confusion and code duplication or removal of code which might impact other features. So git provides an option to create multiple branches, So that each developer can create there own branch and then update the code, push code to their own branch ,finally merge with main branch. Eg: Developer 1 creates a new branch name: dev-login       Developer 2 creates another branch  name: dev-signup. So, Developer 1 and Developer 2 can work on their branch and once every thing is done. They will come together to merge the Login and signup branches to main. Git branching commands: 1. git branch: Use to display all the branches on currently working repo(in our example devopsDemo ) 2. git branch --show-current:  Display the name of current working bra...

DevOps session 10: Git basic commands for daily use

Image
  Create new Repo on GitHub: 1.Go to your GitHub account and on the header ,click on "+" icon ,Then click on New repository. 2. Provide your new Repo name ,Select the public option if you want to show your work with every one.  If you want to show the content in repo to specific users ,then select private . Then click on create repository button at the bottom. 3. Once repository is created, we are navigated to repo dashboard page. 4.  Create a sample README file by clicking on below text in screenshot.  Then go down and click on commit change button. COMMANDS: 1.  git init:  As a first step we need to create a local empty repo. 2.  git clone:  First time when we want to get the code from GitHub repo, we use clone command.      Go to your GitHub repo you want to clone and copy the SSH link. Then use git clone [link copied from above] . 3. git branch a : This commands will display all branches present for that GitHub repo.   ...