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 7: Source Code Management/ Version control systems (GIT) || Setup Git on ubuntu

 




Version control systems(VCM) manage changes to software development projects. Businesses use this software to allow multiple users collaborate on projects and track changes made by each user.




GIT is free, open source version control system. 
  • Version Control System - VCS helps a software team manage changes to source code over time.
  • Version control software keeps track of every modification to the code in a special kind of database. 
  • VCS System helps team to rollback to previous version in case of any issue with specific Version.

Advantages:

There are several reasons why we should manage the source code that we write:

  • Work together in teams. A source code management system allows multiple developers to access and change different areas of the code, without interfering with each other’s work. This is a big benefit for large teams of developers.
  • Version history. The system will keep a history of all saved changes to the code. This not only allows you to see what has changed in a file, but allows you to go back to a previous version if needed.
  • Generate release notes. Code can be linked to a release, and as a result, release notes can be generated. This means time is saved in generating it manually and searching for the changes.
  • Backup of code. A centralised place on a server where the source code is stored ensures there is a main location for the code (other than the developer’s machine). It also allows for easy backup of the code, depending on your server setup.
Terminologies used generally when dealing with SCM.

  • Check out – gets a writeable copy of the code for a single developer
  • Check in – saves the code that has been checked out back into the system, removing any locks placed on it.
  • Commit – same as “check in”, just a different term.
  • Branch – a different version of some code, created from an earlier release, separate to the main version. Similar to a “tree branch” metaphor – branches out from a certain point to form its own line.
  • Merge – combining two or more sets of code together, perhaps as a result of a branch. This process is performed by the source control management system when you need it to.
  • Repository – the server and system used to store the source code.

SETUP GIT on Ubuntu:

Step 1: Update your packages

            cmd: sudo apt update

Step 2: Install git using below command.

            cmd: sudo apt install git


Step 4: Once git installation is done ,Verify the git using below command.

            cmd: git --version


Step 5: Configure Git for first time .This is helpful when multiple people working on single branch.

            cmd: git config --global user.name "Your name"

            cmd:  git config --global user.email "your email"



            cmd: git config --list


To update the configured file, we can use below cmd. 


To save and close the file , Press CTRL and X, then Y then ENTER to exit the text editor.




Comments

Popular posts from this blog

DevOps session 10: Git basic commands for daily use

DevOps session 11: Git branching & best practices