Deployment Git with a VPS

👋 Hi there, I am Nirmal. I am a former software engineer with a keen interest in data science and analytics domains. Besides, I love to contribute to open source and help others to understand various tech stuffs.
Search for a command to run...

👋 Hi there, I am Nirmal. I am a former software engineer with a keen interest in data science and analytics domains. Besides, I love to contribute to open source and help others to understand various tech stuffs.
No comments yet. Be the first to comment.
When it comes to developing software applications, choosing the appropriate architectural style is a critical decision. Among the popular options are microservices and monolithic architecture. By understanding the trade-offs, readers can make well-i...
Bias in Machine Learning Bias refers to the simplifying assumptions made by a model to make the target function easier to learn. High bias can lead to underfitting Represents the error introduced by approximating a real-world problem Example: A li...
When it comes to developing software applications, choosing the appropriate architectural style is a critical decision. Among the popular options are microservices and monolithic architecture. By understanding the trade-offs, readers can make well-i...

In a world where information is everywhere, businesses have tons of data at their fingertips. This data is like a goldmine waiting to be used for smart decisions. That's where Big Data analytics and Data Science come in. They're like the experts who ...

Python is a powerful tool for data professionals, largely due to its extensive collection of open-source libraries and packages. In this blog, we'll explore the fundamentals of pandas, with a special focus on its core data structures: Series and Data...

NumPy is a powerful library for numerical computing in Python, offering robust support for large, multi-dimensional arrays and an extensive collection of mathematical functions. Creating Arrays To begin using NumPy, import the library and create arra...

Git is a powerful version control system that allows developers to efficiently manage their code repositories and collaborate seamlessly with team members. In this step-by-step guide, we will walk you through the process of setting up and using Git in your VPS server in an easy and beginner-friendly way.
Connect to Your VPS Server First, log in to your VPS server using SSH.
ssh your_username@your_server_ip
Install Git: Most VPS servers come with Git pre-installed, but it's always good to verify. To install Git, use the package manager specific to your server's operating system.
# on Ubuntu/Debian
sudo apt-get update
sudo apt-get install git
#On CentOS/RHEL
sudo yum install git
Configure Git:
Before you start using Git, you need to configure your identity. Replace the placeholders with your own name and email address:
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
Check your configuration
git config --list
The git config –list command should return the configuration you added
user.name=YourUserName
user.email=example@example.com
Create the Project Directory: First, create a directory for your project. You can do this using the mkdir command:
mkdir project
Create Files for the Project: Navigate into the project1 directory and create some files and a sub-directory:
$ cd project
$ touch file
Initialize Git in the Project Directory: Next, you need to initialize a Git repository in the project1 directory using the git init command:
git init
This command initializes an empty Git repository in the project directory, allowing Git to track changes in the files.
Add Files to the Repository:
git add .
Make Your Initial Commit: After adding the files, it's time to make your initial commit. A commit is a snapshot of the changes you've made to the project. Each commit should have a meaningful commit message describing the changes.
git commit -m "Initial Commit"
The -m flag allows you to specify the commit message directly in the command. In this case, we use "Initial Commit" to indicate that this is the first commit for the project.
Check if you already have an SSH key pair by running:
ls -al ~/.ssh
Generate SSH Key Pair on VPS: Log in to your VPS via SSH, open a terminal, and run the following command to generate an SSH key pair:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
View and Copy Public Key: After generating the keys, run the following command to display your public key:
cat ~/.ssh/id_rsa.pub
Copy the entire output of the command, which is your public key.
Add Public Key to GitHub:
Click on your profile picture in the upper right
Select settings
Click on SSH and GPG keys
Click on the “Create SSH Key” button
Give the key a “title” to help you identify it
Paste the public key into the “key” field
Save the key
Test SSH Connection: To test if your SSH connection is working, run the following command in the terminal of your VPS:
ssh -T git@github.com
You should see a message like "Hi username! You've successfully authenticated, but GitHub does not provide shell access."
Update Git Configuration: To ensure Git uses SSH for pushing and pulling from GitHub, configure it to use the SSH URL. Run the following commands in your VPS terminal:
git config --global user.email "your_email@example.com"
git config --global user.name "Your Name"
git remote remote add origin git@github.com:your-username/your-repo.git
Now, your VPS should be set up to use SSH for interacting with your GitHub repository. Now , you can clone, push, and pull from GitHub using SSH without needing to enter your username and password each time.