January 24, 2024

GIT Commands

Git and GitHub are essential tools for developers to efficiently manage their code, collaborate with others, and to contribute in open-source projects.

In this Git Tutorial, we’ve covered all the basics to advanced Git commands that the developers required during the development and deployment process. Moreover, it is well-structured and categorized according to different use cases. It includes Git and GitHub, Git download, Git Configuration & Setup, Git commands, Git bash, Creating and Getting Git Projects, Git Snapshots, Branching and Merging in Git, Sharing and Updating in Git, Git Comparison, Managing History in Git, and more.

What is Git?

Git is the free and open-source distributed version control systems that’s responsible for everything GitHub related that happens locally on your computer.

Understanding Version Control

Version control, also known as source control, is the technique of tracking and managing changes to codes and these are the systems that are software tools that enable software teams to manage modifications to source code as time passes.

What is GitHub?

GitHub is a widely-used Free-to-use cloud Storage platform with version control and many other essential features that specifically helps developers to manage and deploy their projects on GitHub.

Benefits of Using Git

  1. History Tracking: Git allows you to track every change made in your project, including: who made the change and when it was made.
  2. Collaboration: Multiple developers can be able work on the same project at the same time, and Git efficiently manages the merging of changes in code.
  3. Branching and Merging: Git enables developers to create branches to work on new features or bug fixes and later merge them back into the main codebase.
  4. Offline Work: Git works offline, which means you can commit changes and work on your project even without an internet connection.

Learn Git Cheat Sheet (Basic to Advanced Concepts)

Git Configuration & Setup

  • git config –global user.name <userName>: Set your username globally.
  • git config –global user.email <email>: Set your email globally.
  • git config –global color.ui auto – Set to display colored output in the terminal
  • git help: Display the main help documentation, showing a list of commonly used Git commands.

Initializing a Repository 

  • git init: Initializes a new Git repository in the current directory.
  • git init <directory>: Creates a new Git repository in the specified directory.
  • git clone <repository_url>: This Clones a repository from a remote server to your local machine.
  • git clone –branch <branch_name> <repository_url>: Clones a specific branch from a repository.

Basic Git Commands

  • git add <file>: Adds a specific file to the staging area.
  • git add . or git add –all: Adds all modified and new files to the staging area.
  • git status: Shows the current state of your repository, including tracked and untracked files, modified files, and branch information.
  • git status –ignored: Displays ignored files in addition to the regular status output.
  • git diff: Shows the changes between the working directory and the staging area (index).
  • git diff <commit1> <commit2>: Displays the differences between two commits.
  • git diff –staged or git diff –cached: Displays the changes between the staging area (index) and the last commit.
  • git diff HEAD: Display the difference between the current directory and the last commit
  • git commit: Creates a new commit with the changes in the staging area and opens the default text editor for adding a commit message.
  • git commit -m "<message>" or  git commit –message "<message>": Creates a new commit with the changes in the staging area and specifies the commit message inline.
  • git commit -a or git commit –all: Commits all modified and deleted files in the repository without explicitly using git add to stage the changes.
  • git notes add: Creates a new note and associates it with an object (commit, tag, etc.).
  • git restore <file>: Restores the file in the working directory to its state in the last commit.
  • git reset <commit>: Moves the branch pointer to a specified commit, resetting the staging area and the working directory to match the specified commit.
  • git reset –soft <commit>: Moves the branch pointer to a specified commit, preserving the changes in the staging area and the working directory.
  • git reset –hard <commit>: Moves the branch pointer to a specified commit, discarding all changes in the staging area and the working directory, effectively resetting the repository to the specified commit.
  • git rm <file>: Removes a file from both the working directory and the repository, staging the deletion.
  • git mv: Moves or renames a file or directory in your Git repository.

Branching and Merging

  • git branch: Lists all branches in the repository.
  • git branch <branch-name>: Creates a new branch with the specified name.
  • git branch -d <branch-name> : Deletes the specified branch.
  • git branch -a: Lists all local and remote branches.
  • git branch -r: Lists all remote branches.
  • git checkout <branch-name>: Switches to the specified branch.
  • git checkout -b <new-branch-name>: Creates a new branch and switches to it.
  • git checkout  -- <file>: Discards changes made to the specified file and revert it to the version in the last commit.
  • git merge <branch>: Merges the specified branch into the current branch.
  • git log: Displays the commit history of the current branch.
  • git log <branch>: Displays the commit history of the specified branch.
  • git log –follow <file>: Displays the commit history of a file, including its renames.
  • git log –all: Displays the commit history of all branches.
  • git stash: Stashes the changes in the working directory, allowing you to switch to a different branch or commit without committing the changes.
  • git stash list: Lists all stashes in the repository.
  • git stash pop: Applies and removes the most recent stash from the stash list.
  • git stash drop: Removes the most recent stash from the stash list.
  • git tag: Lists all tags in the repository.
  • git tag <tag-name>: Creates a lightweight tag at the current commit.
  • git tag <tag-name> <commit>: Creates a lightweight tag at the specified commit.
  • git tag -a <tag-name> -m "<message>": Creates an annotated tag at the current commit with a custom message.

Remote Repositories

  • git fetch: Retrieves change from a remote repository, including new branches and commit.
  • git fetch <remote>: Retrieves change from the specified remote repository.
  • git fetch –prune: Removes any remote-tracking branches that no longer exist on the remote repository.
  • git pull: Fetches changes from the remote repository and merges them into the current branch.
  • git pull <remote>: Fetches changes from the specified remote repository and merges them into the current branch.
  • git pull –rebase: Fetches changes from the remote repository and rebases the current branch onto the updated branch.
  • git push: Pushes local commits to the remote repository.
  • git push <remote>: Pushes local commits to the specified remote repository.
  • git push <remote> <branch>: Pushes local commits to the specified branch of the remote repository.
  • git push –all: Pushes all branches to the remote repository.
  • git remote: Lists all remote repositories.
  • git remote add <name> <url>: Adds a new remote repository with the specified name and URL.

Git Comparison

  • git show: Shows the details of a specific commit, including its changes.
  • git show <commit>: Shows the details of the specified commit, including its changes.

Git Managing History

  • git revert <commit>: Creates a new commit that undoes the changes introduced by the specified commit.
  • git revert –no-commit <commit>: Undoes the changes introduced by the specified commit, but does not create a new commit.
  • git rebase <branch>: Reapplies commits on the current branch onto the tip of the specified branch.

Why use Git?

Here are some of the reasons why you might want to use Git:

  1. Track changes to your code
  2. Collaborate on projects with others
  3. Maintain an organized code history
  4. Easily revert to previous versions when needed
  5. Release your code efficiently and manage versions
  6. Enhance productivity and code integrity in software development.

Conclusion

In conclusion, This is thoughtfully organized and categorized, making it easy for developers to quickly find the commands they need for specific use cases. Whether it’s configuring and setting up Git, creating and managing projects, taking snapshots, branching and merging, sharing and updating, comparing changes, or managing version history.

By utilizing this resource, developers can enhance their productivity and efficiency in working with Git, ultimately leading to smoother and more successful software development projects.

January 23, 2024

Setting up Jenkins on Amazon AWS - EC2 RHEL 9 (Red Hat Enterprise Linux)

Step#1: Creating EC2 RHEL Instance

  1. Create AWS Account
  2. Login to https://ap-southeast-2.console.aws.amazon.com/ec2/home?region=ap-southeast-2#Home (AWS Credentials)
  3. Click on Launch Instance
    1. Provide Name
    2. Select RedHat
    3. Select Amazon Machine Image (AMI)
    4. Select Instance type(t2.micro - Default)
    5. Select/Create Key pair name
      1. Create KeyPar:
        1. Key Pair Name: mykeypair
        2. Key Pare Type: RSH
        3. Private key file format: .pem
        4. Save the private key securely in your local machine
    6. Click on Edit button "Network settings"
      1. Inbound Security Group Rules
        1. Add Security Group
          1. Type: Custom TCP
          2. Port Range: 8080
          3. Source Type: Any where
    7. Click on 'Launch Instance"
  4. EC2 Instance is created. Wait Until is started (Instance State: Running; Status check: 2/2 checks passed)
  5. Get the "Public IPv4 address"

Step#2: Accessing Instance from Console

I Used MobaXTerm App to access the EC2 instance
  1. Open CMD/ MobaXTerm (App)
  2. Click on Session
  3. Select SSH
    1. Enter Remote Host Name/ID (Public IPv4 address), Port 22
    2. Advanced SSH Settings: browser SSH Key (use private SSH key)
    3. Ok

Step#3: Command to Enter on the EC2 Instance

  1. sudo yum -y install wget
    • This is to install wget on RHEL
  2. sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
  3. sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
    • These two lines are for downloading the stable version of jenkins from internet.
  4. sudo yum install fontconfig java-17-openjdk
    • We require java for the functioning of jenkins.
  5. java -version
    • Ensure Java installed properly
  6. sudo yum install jenkins
    • Install Jenkins
  7. sudo systemctl daemon-reload
    • Reload systemd manager configuration. This will rerun all generators
  8. sudo systemctl status jenkins
    • To check the status of the Jenkins service
  9. sudo systemctl start jenkins
    • To Start the Jenkins service
    • Jenkins Password (This may also be found at: var/lib/jenkins/secrets/initialAdminPassword)
  10. sudo systemctl status jenkins
    • To check the status of the Jenkins service
  11. sudo systemctl enable jenkins
    • To enable the Jenkins service to start at boot with the command

Step#4: Launching Jenkins

  1. Open Browser - http://<Public_IP>:8080 --> Public IP can be found at Step#1.5
  2. Enter Jenkins Password --> Jenkins Password can be found at Step#3.9.2 or var/lib/jenkins/secrets/initialAdminPassword
  3. Create admin user - Save & Next
  4. Jenkins URL will be shown (you can change if you want)
  5. Save and Finish

January 17, 2024

Testing Methodology?
Means what kind of approach is following while testing (e.g.) functional testing, Regression testing, Retesting, Confirmation testing.

Exploratory Testing:
With out the knowledge of requirements, testing is done by giving random inputs.

Ad-Hoc testing:
Testing without a formal test plan or outside of a test plan.

Test plan:
Test plan specifies process and scheduling of an application. Test lead
Prepares test plan document based on what to test, how to test, when to test, whom to test. It covers the entire testing activity.

SRS: 
Software requirement specification (SRS). It describes what the software will do and how it will be expected to perform.

Requirement Traceability Matrix (RTM):
It is the mapping between customer requirements and prepared test cases. This is used to find whether all the requirements are covered or not.

Software testing lifecycle:
  1. Requirements gathering: Collecting the project related information.
  2. Analyzing: Discussing the collected information whether the requirements can meet.
  3. Test plan preparation: It specifies the entire testing activity
  4. Test case preparation: It is a document which contains input and corresponding results.
  5. Test case execution: Execution of test case results to find bugs
  6. Bug Tracking: Monitoring of the bug till closed.
  7. Regression testing: Testing the application to find whether the change in code affect anywhere in the application.