❌

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

Hosting a static website on Heroku – The easy way

By: ashish
26 July 2019 at 18:06

Image credits : milesweb.com

Do you want free hosting for your demo website? Do you want to deploy your webapp for free? Then look no further. You can do that and more with Heroku.Β  Read more to deploy your first static website on Heroku.

Heroku is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud. Heroku has a genorous free plan allowing students/hobbyist to deploy their apps on the cloud for free.

In this post you are going to learn the following –

  • Basics of git
  • Adding files necessary to host static HTML on Heroku
  • Pushing code to your git repo
  • Creating a new app on Heroku and connecting it with your GitHub account

What you’ll need –

  1. A GitHub account ( if you are a student, apply for a student pack here)
  2. A Heroku account ( if you are a student , avail your benefits here)

1. Git

What is Git?

Git is a version control tool. Think of it like a backup of your code, but instead of backing up all your code, it just backs up the changes. Watch the following video to learn more about git and github.

For the purpose of this blog post, I am going to use a sample website from microsoft sample html project. Considering you are already registered on GitHub, go to the page and click on fork. This will copy all the code to your account so that you can make changes to it.

Once that is done, you need to download and install git on your machine. After installing git, head over to your cmd prompt and copy/paste the following

git clone https://github.com/< username >/project-html-website

Make sure you replace the < username > with your own github username, and that you have already forked the project.

Once you run the above command, the project will be copied to your local directory. Go ahead and check it out.

Click on the image to learn basic git commands

2. Adding files necessary to host static HTML on Heroku

  • Add a file called composer.json in the directory. If you want to learn more about why we are adding a composer.json file to the directory – click here.Β 
  • Inside the composer.json file add the following line –
  • { }
  • Add another file called index.php. If you want to know more about index files – click here.
  • Inside index.php add the following line –
  • <?php include_once("index.html"); ?>
  • You can replace index.html with the name of the html file you want to server as your home page.

Your folder structure should now look like this

Let us now push these local changes to our github repo. To do that change directory into the folder using – cd directoryΒ and perform the following commands.

3. Pushing code to your git repo

If everything goes well you should have the same output as I have in the above screen shot. Let’s go over the commands one by one

  • cd project-html-website
  • is to change the directory of the terminal into the project folder
  • Once we are in the project folder, we add/propose changed to git by
  • git add *
  • git commit -m "commit message"
  • And finally the
  • git push
  • To push all the local changes to the github server.

4. Creating a new app on Heroku

  • Go to your Heroku dashboard and create a new app.
  • Give the app a suitable name and click on Create app.
  • Once that is done, you will be redirected to the deploy page for your new app.
  • Click on GitHub and connect your app to your GitHub repo.
  • Once you are connected, scroll down and click on the deploy brach button.
  • Once it is deployed, you can see the website with its own unique Heroku url.
  • View my app here

Hope this post helped you. If you want more help, feel free to ping meΒ @Ashish_che

Types of Version Control System

18 July 2024 at 11:05
version control system tracks changes to a file or set of files over time. There are three types of version control system: Local Version Control Systems: Centralized Version Control Systems: Distributed Version Control Systems: Popular version control systems and tools Here’s a brief overview of some commonly used version control tools and their pros and […]

Git Commands

By: Elavarasu
2 March 2024 at 12:24
  • git clone
  • git add
  • git commit
  • git push
  • git pull
  • git branch
  • git checkout
  • git status

git clone remote

to create new repository in github cloud , then create a local repo and clone 2 repositories using git clone remote (repo link).

git add filename
git add .

to add a single file using git add and add all the files which present in the current repo the use git add . | . represent add all the files.

git commit -m "message"

commit the added file using git commit and put some mesagges about the file using -m ” ” .

some ideas of commit messages are available in below mentioned link.

Reference : conventional commit.org | https://www.conventionalcommits.org/en/v1.0.0/

git rm --cached filename
if incase want to remove the added file use git remove
git rm --cached -f filename
-f --> forcefully remove the file.
git push

push the commited file from the local to cloud repo using git push. it will push the file to remote repository.

git pull 

when u need to change or edit or modify the remote file first you will pull the file to local repository from remote using git pull.

git branch 
Branch means where will you store the files in git remote.git branch is to specify the branch name it will push the file to current remote branch.

git checkout -b "branchname"
to create a new branch.

git checkout branchname
check the created branch or new branch

git branch -M branchname
to modify or change the branch name

git branch -a
to listout all branches.
git status
check all the status of previously used command like know the added file is staged or unstaged

Reference : https://www.markdownguide.org/cheat-sheet/

markdown cheathseet for readme file

Reference : conventional commit.org | https://www.conventionalcommits.org/en/v1.0.0/

for commit messages.

Git Commands

By: Elavarasu
2 March 2024 at 12:24
  • git clone
  • git add
  • git commit
  • git push
  • git pull
  • git branch
  • git checkout
  • git status

git clone remote

to create new repository in github cloud , then create a local repo and clone 2 repositories using git clone remote (repo link).

git add filename
git add .

to add a single file using git add and add all the files which present in the current repo the use git add . | . represent add all the files.

git commit -m "message"

commit the added file using git commit and put some mesagges about the file using -m ” ” .

some ideas of commit messages are available in below mentioned link.

Reference : conventional commit.org | https://www.conventionalcommits.org/en/v1.0.0/

git rm --cached filename
if incase want to remove the added file use git remove
git rm --cached -f filename
-f --> forcefully remove the file.
git push

push the commited file from the local to cloud repo using git push. it will push the file to remote repository.

git pull 

when u need to change or edit or modify the remote file first you will pull the file to local repository from remote using git pull.

git branch 
Branch means where will you store the files in git remote.git branch is to specify the branch name it will push the file to current remote branch.

git checkout -b "branchname"
to create a new branch.

git checkout branchname
check the created branch or new branch

git branch -M branchname
to modify or change the branch name

git branch -a
to listout all branches.
git status
check all the status of previously used command like know the added file is staged or unstaged

Reference : https://www.markdownguide.org/cheat-sheet/

markdown cheathseet for readme file

Reference : conventional commit.org | https://www.conventionalcommits.org/en/v1.0.0/

for commit messages.

GitHub, Git & Jenkins

13 February 2024 at 03:32

Github:

It allows collaboration with any developer all over the world. Open Source solutions enable potential developer to contribute and share the knowledge to benefit the Global Community. At a high level, GitHub is a website and cloud-based service that helps developers store and manage their code, as well as track and control changes to their code. To understand exactly what GitHub is, you need to know two connected principles:

  • Version control
  • Git

What Is Version Control?

Version control helps developers track and manage changes to a software project’s code. As a software project grows, version control becomes essential. Take WordPress…

At this point, WordPress is a pretty big project. If a core developer wanted to work on one specific part of the WordPress codebase, it wouldn’t be safe or efficient to have them directly edit the β€œofficial” source code.

Instead, version control lets developers safely work throughΒ branchingΒ andΒ merging.

WithΒ branching, a developer duplicates part of the source code (called theΒ repository). The developer can then safely make changes to that part of the code without affecting the rest of the project.

Then, once the developer gets his or her part of the code working properly, he or she canΒ mergeΒ that code back into the main source code to make it official.

What Is Git?

Git is aΒ specific open-source version control systemΒ created by Linus Torvalds in 2005.It is used for coordinating work among several people on a project and track progress over time. It is used for source code management for software development.

GitHub is a Git repository hosting service which provides a web-based graphical interface that helps every team member to work together on the project from anywhere and makes it easy to collaborate.

Jenkins

Jenkins isΒ a Java-based open-source automation platform with plugins designed for continuous integration.

It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration, and continuous delivery, making it easier for developers and DevOps engineers to integrate changes to the project and for consumers to get a new build. It is a server-based system that runs in servlet containers such as Apache Tomcat.

Git vs Jenkins: What are the differences?

Git and Jenkins are both popular tools, Git is a distributed version control system and Jenkins is a continuous integration and automation tool. Let’s explore the key differences between the two:

  1. Code Management vs. Automated Builds: Git is primarily used for code management and version control. It allows developers to track changes, collaborate on code, and handle code branching and merging efficiently. On the other hand, Jenkins focuses on automated builds, testing, and deployment. It helps in integrating code changes from multiple team members and automates the build process, including compiling, testing, and packaging the software.
  2. Local vs. Remote: Git operates locally on the developer’s machine, allowing them to work offline and commit changes to their local repository. Developers can then push their changes to a remote repository, facilitating collaboration with other team members. In contrast, Jenkins is a remote tool that runs on a dedicated server or cloud platform. It continuously monitors the code repository and triggers automated builds or tests based on predefined conditions or schedules.
  3. Version Control vs. Continuous Integration: Git’s primary focus is on version control, tracking changes to files and directories over time. It provides features like branching, merging, and resolving conflicts to manage code versions effectively. Jenkins, on the other hand, emphasizes continuous integration (CI), which involves frequently integrating code changes from multiple developers into a shared repository. Jenkins automatically builds and tests the integrated code, highlighting any conflicts or issues that arise during the process.
  4. User Interface: Git primarily relies on a command-line interface (CLI) for executing various operations. However, there are also graphical user interface (GUI) clients available for more user-friendly interactions. Jenkins, on the other hand, provides a web-based graphical user interface that allows users to configure and manage Jenkins jobs, view build reports, and monitor the status of automated builds and tests.
  5. Plugin Ecosystem: Git has an extensive ecosystem of third-party plugins that extend its functionality and integrations with other development tools. These plugins cover various areas, including code review, issue tracking, and build automation. Jenkins, being an automation tool, has a rich plugin ecosystem as well. These plugins enable users to integrate Jenkins with different build tools, testing frameworks, version control systems, and deployment platforms, enhancing its capabilities and flexibility.
  6. Ease of Use: Git can have a steep learning curve for beginners, particularly when it comes to understanding concepts like branching, merging, and resolving conflicts. However, once users become familiar with its core functionality, it provides a powerful and flexible version control system. Jenkins, on the other hand, aims to simplify the CI process and provide an intuitive user interface for managing builds and automation. While some initial setup and configuration may be required, Jenkins offers ease of use in terms of managing continuous integration workflows.

In summary, Git focuses on code management and version control, while Jenkins specializes in continuous integration and automation. Git operates locally, while Jenkins runs remotely on dedicated servers. Git’s primary interface is command-line-based, with additional GUI clients available, whereas Jenkins offers a web-based graphical user interface. Both Git and Jenkins have plugin ecosystems that extend their functionality, but Jenkins prioritizes automation-related integrations. Finally, while Git has a steeper learning curve, Jenkins aims to provide ease of use in managing continuous integration workflows.

Source: https://stackshare.io/stackups/git-vs-jenkins#:~:text=Git%20operates%20locally%2C%20while%20Jenkins,web%2Dbased%20graphical%20user%20interface.

Visual Studio Code (VSCode) and then commit it to a GitHub repository

15 December 2023 at 13:58

To commit HTML code to a GitHub repository using Visual Studio Code (VSCode), follow these steps:

  1. Install Git: Make sure Git is installed on your system. You can download it from Git's official website and follow the installation instructions.

  2. Set up Git in VSCode:

    • Open VSCode and open your project folder.
    • Press Ctrl + Shift + P (or Cmd + Shift + P on macOS) to open the Command Palette.
    • Type "Git: Initialize Repository" and select your project folder to initialize Git.
  3. Create a new GitHub repository:

    • Go to GitHub and log in to your account.
    • Click on the "+" icon in the top-right corner and select "New repository."
    • Follow the instructions to create a new repository on GitHub.
  4. Link the local repository to GitHub:

    • In VSCode, open the terminal by pressing Ctrl + ` (backtick) or navigating to View > Terminal in the top menu.
    • Use the following commands to link your local repository to the GitHub repository you created:
   git remote add origin <repository_url>

Replace <repository_url> with the URL of your GitHub repository.

  1. Add and commit HTML files:

    • In VSCode, navigate to the Source Control view by clicking on the source control icon in the left sidebar (or press Ctrl + Shift + G).
    • You'll see a list of changed files. Stage the HTML files you want to commit by clicking the + button next to the file names.
    • Enter a commit message in the text box at the top of the Source Control view to describe the changes you made.
    • Click the checkmark icon to commit the changes.
  2. Push changes to GitHub:

    • After committing the changes, click on the ellipsis (...) icon in the Source Control view and select "Push."
    • This action will push your committed changes to the GitHub repository.

Remember, these instructions assume you've set up a GitHub repository and have the necessary permissions to push changes to it. If you encounter any authentication issues during the push, make sure your GitHub credentials are correctly configured in Git or that you've set up SSH keys for GitHub authentication.

Step 1: Set up Git and GitHub

  1. Install Git: Download and install Git from Git's official website.

  2. Create a GitHub repository: Go to GitHub and log in to your account. Create a new repository by clicking the "+" icon in the top-right corner and selecting "New repository."

Step 2: Create an index.html file

  1. Open Visual Studio Code.
  2. Click on File in the top-left corner, select Open Folder..., and choose or create a new folder for your project.

Step 3: Create and code the index.html file

  1. In VSCode, right-click on the folder you created and select New File. Name the file index.html.
  2. Add HTML code to the index.html file. For example:
<!DOCTYPE html>
<html>
<head>
  <title>My First Web Page</title>
</head>
<body>
  <h1>Hello, World!</h1>
  <p>This is a simple HTML page.</p>
</body>
</html>

Step 4: Initialize Git repository and commit changes

  1. Open the integrated terminal in VSCode by going to Terminal > New Terminal.

  2. Initialize Git in your project folder by typing the following command in the terminal:

git init
  1. Add the index.html file to the staging area by typing:
git add index.html
  1. Commit the changes with a descriptive message:
git commit -m "Add index.html file with basic HTML structure"

Step 5: Link local repository to GitHub

  1. Go to your GitHub repository and copy the repository URL (ending in .git).

  2. In the terminal, link your local repository to the GitHub repository by running the following command:

git remote add origin <repository_url>

Replace <repository_url> with the URL you copied from GitHub.

Step 6: Push changes to GitHub

  1. Finally, push your committed changes to GitHub:
git push -u origin main

This command pushes your changes from the local main branch to the main branch on GitHub.

After completing these steps, your index.html file will be committed and pushed to your GitHub repository. You can verify the changes by visiting your GitHub repository in a web browser

Author:
Muthukumar.K

Project#1:

26 September 2023 at 06:22

To achieve the tasks you've outlined, you'll need to follow these steps:

  1. Create a GitHub Repo with HTML Page:
  • Create a new GitHub repository.
  • Add an HTML file (e.g., index.html) to the repository.
  1. Create a Dockerfile:
  • In your GitHub repository, create a Dockerfile that defines how to build your Docker image. Here's a simple example:
   # Use an official Nginx runtime as a parent image
   FROM nginx:alpine

   # Copy your HTML file into the Nginx web root directory
   COPY index.html /usr/share/nginx/html

   # Expose port 80 to listen for incoming HTTP requests
   EXPOSE 80

   # Start Nginx
   CMD ["nginx", "-g", "daemon off;"]
  1. Write a Shell Script:

Create a shell script (e.g., build_and_run.sh) with the following content:

   #!/bin/bash

   # Clone the GitHub repo
   git clone https://github.com/yourusername/your-repo.git

   # Navigate to the repo directory
   cd your-repo

   # Build the Docker image
   docker build -t your-image-name .

   # Push the Docker image to Docker Hub
   docker push your-dockerhub-username/your-image-name

   # Run the Docker container
   docker run -d -p 80:80 your-dockerhub-username/your-image-name

Make sure to replace yourusername, your-repo, your-image-name, and your-dockerhub-username with your actual GitHub and Docker Hub information.

  1. Execute the Shell Script via Cron:

To run the shell script every 10 minutes, you can set up a cron job. Edit your crontab file by running:

   crontab -e

Then add the following line to schedule the script execution:

   */10 * * * * /path/to/build_and_run.sh

Replace /path/to/build_and_run.sh with the actual path to your shell script.

  1. Make Changes to index.html:

Edit your index.html file in your GitHub repository to make the desired changes.

  1. Check the Browser After 15 Minutes:

After making changes to index.html, commit and push the changes to your GitHub repository. Wait for 15 minutes, and the updated content should be reflected when you access the website in your browser.

  1. Push the Build Shell Script to the Same Repo:

Add the build_and_run.sh shell script to your GitHub repository:

   git add build_and_run.sh
   git commit -m "Add build_and_run.sh script"
   git push

Now you have a setup that automatically builds and deploys your HTML page using Docker, updates it every 10 minutes via a cron job, and reflects changes in the browser after 15 minutes when you make updates to index.html.

"Supercharge Your Github Journey: Must-Know Command Line Commands for Beginners"

By: Kannan
2 September 2023 at 20:02

Introduction

GitHub has become an indispensable platform for developers. It allows collaboration, version control, and seamless code integration. To fully leverage GitHub's potential, it's crucial to understand the role of command line commands in enhancing your workflows.

Getting Started with GitHub

Setting up a GitHub account

Visit github.com and sign up for a free account.

Complete the necessary information, including your username and email address.

Verify your email to activate your account.

Understanding repositories and commits

Repositories are containers for project code. They serve as a central hub for file management and collaboration.

Commits are snapshots of your code at a specific point in time. They represent changes made to the repository.

Introduction to Command Line Interface (CLI)

The Command Line Interface (CLI) plays a fundamental role in navigating and controlling GitHub workflows. It allows developers to interact with GitHub directly from their terminal.

Installing and configuring a CLI

Choose a CLI tool, such as Git or GitHub CLI, and install it on your machine.

Configure the CLI by setting your username and email address for proper identification.

Basic Command Line Commands

To navigate and manipulate files and directories efficiently, it's crucial to familiarize yourself with basic command line commands.

  • Navigating directories and files

Use the "cd" command to change directories.

kannan@kannan-PC:~$ cd newrepo
kannan@kannan-PC:~/newrepo$

Utilize the "ls" command to list files and directories within the current directory.

kannan@kannan-PC:~/newrepo$ ls
1.php  2.py   4.php        file3.txt   newfile3.txt  README.md
1.py   3.php  4.py         header.php  newfile.txt   sample.txt
2.php  3.py   example.txt  index.html
  • Creating and deleting files and directories Create a new file using the "touch" "vim" command.
kannan@kannan-PC:~/newrepo$ touch testfile.txt

Remove files or directories with the "rm" command.

kannan@kannan-PC:~/newrepo$ rm testfile.txt 
  • Modifying file permissions

Adjust file permissions using the "chmod" command.

Grant or revoke read, write, or execute permissions to authorized users.

kannan@kannan-PC:~/newrepo$ git add --chmod=+x testfile.txt

  • Initializing a Git

A Git repo is essential for version control. Initializing a repository allows you to track changes and collaborate effectively.

sudo apt update
sudo apt install git
git --version
  • Initializing a local repository

Use the "git init" command to set up a repository in your current directory.

This creates a hidden ".git" folder that stores repository information.

git init
  • Creating a repository

Image description

  • Cloning an Git repository

Clone an repository using the "git clone" command followed by the repository's URL.

This creates a local copy of the remote repository on your machine.

kannan@kannan-PC:~$ git clone git@github.com:kannanb95/samplerepo.git
Cloning into 'samplerepo'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
  • Command Line for Repository Management

Efficient repository management involves regularly checking the status, adding, committing, and handling changes made to your code.

  • Checking repository status

Use the "git status" command to see the current state of your repository.

kannan@kannan-PC:~$ cd samplerepo
kannan@kannan-PC:~/samplerepo$ ls
README.md
kannan@kannan-PC:~/samplerepo$ touch testfile.txt
kannan@kannan-PC:~/samplerepo$ git status
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    testfile.txt

nothing added to commit but untracked files present (use "git add" to track)

It shows which files are modified, staged, or untracked.

  • Adding and committing changes

Add files to the staging area with the "git add" command.

kannan@kannan-PC:~/samplerepo$ git add testfile.txt
kannan@kannan-PC:~/samplerepo$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
    new file:   testfile.txt

Commit and push your changes using the "git commit"
"git push"command, providing a descriptive message.

kannan@kannan-PC:~/samplerepo$ git commit -m "commit testfile"
[main a588666] commit testfile
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 testfile.txt

kannan@kannan-PC:~/samplerepo$ git push origin main
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 440 bytes | 440.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
To github.com:kannanb95/samplerepo.git
   322930c..c3f05aa  main -> main


  • Reverting commits

Undo commits with the "git revert" command to create a new commit that reverses the changes.

kannan@kannan-PC:~/samplerepo$ git reflog
a588666 (HEAD -> main) HEAD@{0}: checkout: moving from main to main
a588666 (HEAD -> main) HEAD@{1}: commit: commit testfile
13fa75f (origin/main, origin/HEAD) HEAD@{2}: clone: from github.com:kannanb95/samplerepo.git
kannan@kannan-PC:~/samplerepo$ git revert a588666
[main 18c1c71] Revert "commit testfile"
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 testfile.txt

  • GitHub Collaboration with CLI

Collaboration on GitHub is enhanced through the use of branches, which allow multiple developers to work on different features simultaneously.

Image description

They enable parallel work on different features or bug fixes.

  • Creating and switching branches

Create a new branch with the "git branch" command.

kannan@kannan-PC:~/samplerepo$ git branch project
kannan@kannan-PC:~/samplerepo$ git branch testing
kannan@kannan-PC:~/samplerepo$ git branch
* main
  project
  testing

Switch between branches using the "git checkout" command.

kannan@kannan-PC:~/samplerepo$ git checkout project
Switched to branch 'project'
kannan@kannan-PC:~/samplerepo$ git branch
  main
* project
  testing
  • Merging branches

Merge branches together using the "git merge" command.

This incorporates changes from one branch into another.

kannan@kannan-PC:~/samplerepo$ git branch
  main
* project
  testing
kannan@kannan-PC:~/samplerepo$ ls
README.md  testfile2.txt  testfile3.txt  testfile.txt
kannan@kannan-PC:~/samplerepo$ git checkout main
Switched to branch 'main'
kannan@kannan-PC:~/samplerepo$ git branch
* main
  project
  testing
kannan@kannan-PC:~/samplerepo$ ls
README.md  testfile2.txt  testfile3.txt
kannan@kannan-PC:~/samplerepo$ git merge project 
Updating 18c1c71..1e5971a
Fast-forward
 testfile.txt | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 testfile.txt
kannan@kannan-PC:~/samplerepo$ ls
README.md  testfile2.txt  testfile3.txt  testfile.txt
  • Adding and managing remotes

Add a remote repository with the "git remote add" command.

git remote add origin git@github.com:User/UserRepo.git

Pushing and pulling changes

Push local changes to a remote repository using the "git push" command.

kannan@kannan-PC:~/samplerepo$ git push origin project
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 580 bytes | 580.00 KiB/s, done.
Total 5 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), done.
remote: 
remote: Create a pull request for 'project' on GitHub by visiting:
remote:      https://github.com/kannanb95/samplerepo/pull/new/project
remote: 
To github.com:kannanb95/samplerepo.git
 * [new branch]      project -> project

Fetch and merge remote changes into your local repository with the "git pull" command.

kannan@kannan-PC:~/samplerepo$ git pull origin project 
From github.com:kannanb95/samplerepo
 * branch            project    -> FETCH_HEAD
Already up to date.
  • Reviewing changes using CLI tools

Use the "git diff" command to view changes between commits, branches, or files.

kannan@kannan-PC:~/samplerepo$ git status
On branch project
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
    new file:   testfile2.txt
    new file:   testfile3.txt

kannan@kannan-PC:~/samplerepo$ git diff
kannan@kannan-PC:~/samplerepo$ cat > testfile2.txt
hi i have made some changes here
kannan@kannan-PC:~/samplerepo$ git diff
diff --git a/testfile2.txt b/testfile2.txt
index e69de29..7859618 100644
--- a/testfile2.txt
+++ b/testfile2.txt
@@ -0,0 +1 @@
+hi i have made some changes here

Understand which lines were added, modified, or removed.

  • Few Git Cmds Rebase between branch and main
git rebase 

To save the work files on branch (before add&commit)

kannan@kannan-PC:~/samplerepo$ git stash
Saved working directory and index state WIP on project: 1e5971a commit file

To find git log status

kannan@kannan-PC:~/samplerepo$ git log --oneline
1e5971a (HEAD -> project, origin/project) commit file
18c1c71 (testing, main) Revert "commit testfile"
a588666 commit testfile
13fa75f Initial commit

Git File move cmds "git mv"

git mv -f file1.txt file2.txt
git mv -nf file1.txt file2.txt
git mv -k source.txt destination.txt 
git mv -v filea.txt fileb.txt

Git reset cmds "git reset"

git reset --hard <commit id>    complete delete files
git reset -- soft  <commit id>    under staged state
git reset --mixed <commit id>   its default and unstaged state

To view commit status "git show "

kannan@kannan-PC:~/samplerepo$ git show a588666
commit a588666b9499a54da06eafca87e44ebb193c8c4c
Author: kannanb95 <142100996+kannanb95@users.noreply.github.com>
Date:   Sat Sep 2 23:14:52 2023 +0530

    commit testfile

diff --git a/testfile.txt b/testfile.txt
new file mode 100644
index 0000000..e69de29

Git show cmds

git show --pretty=oneline <commit_id>
git show --pretty=short <commit_id>
git show --pretty=medium <commit_id>
git show --pretty=full <commit_id>
git show --pretty=fuller <commit_id>
git show --pretty=raw <commit_id>

Using SSH for GitHub Passwordless Authentication
Authenticating with GitHub typically involves using an access token or password. However, these methods can be inconvenient and insecure, especially when accessing GitHub from multiple devices.

GitHub provides the option to use Secure Shell (SSH) for authentication. SSH presents a secure network protocol for remote machine access. This feature proves especially valuable in situations that demand automation or frequent remote access.

  1. Setting Up SSH for GitHub
ssh-keygen -t rsa -b 4096 -C "youremail@domain.com"

Generating public/private rsa key pair.
Enter file in which to save the key (/home/vagrant/.ssh/id_rsa):

Run the following cmd to get the public key content

cat ~/.ssh/id_rsa.pub
  1. Adding the Public Key to GitHub
    Log in to your GitHub account and go to your Account Settings.
    Click on SSH and GPG keys located on the left sidebar.
    Click on New SSH key.
    Give your SSH key a Title.
    Paste the public key content into the Key field.
    click on the Add SSH key to save the SSH key to your GitHub account.

  2. Configuring an SSH Agent

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

Now you can explore the passwordless Authentication using SSH.
We can also explore with different methods like "cached method","unset method" and "stored method".

Summary

In this comprehensive guide, we covered a wide range of command line commands for mastering GitHub. By familiarising yourself with these essential tools, you've taken a significant step towards unleashing the full potential of GitHub in your development journey. Remember, continuous learning and practice will further solidify your understanding and expertise. Enjoy your supercharged GitHub adventures!

Github Configuration Commands

29 August 2023 at 21:42
sudo apt update git
sudo apt install git
git --version
git config --global user.name "Muthukumark98"
git config --global user.email "muthukumar1998mk98@gmail.com"
git config --list
pwd
mkdir workspace
cd workspace/
git clone https://github.com/Muthukumark98/hello_test.git
ls
cd hello_test/
touch hello.py
ls
cat README.md 
ls
vim hello.py
cat hello.py
git status
git add hello.py
git status
git commit -m "first python code"
git status
git push origin main
git remote set-url origin https://<token>/<username>/<repo>
git push origin main
❌
❌