Configure Git on a Linux Server
To set up a Git environment on a CentOS Linux server, follow these steps:
- Make sure Git is installed on the server. If it is not installed, you can install it on CentOS with the following command:
sudo yum install git
- Open the terminal and log in to the server with root privileges.
- Create a new Git repository directory to store code and related files. For example, create a directory named
my-repo:
mkdir ~/my-repo
cd ~/my-repo
- Initialize a Git repository in that directory using the following command:
git init
- Configure Git credentials. Set your username and email address with the following commands:
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"
- Add the remote repository URL to your local Git configuration. For example, add the remote repository URL as
origin:
git remote add origin https://github.com/NeverGpDzy/Personal-Code.git
- Push code to the remote repository. Use the following command to push local code to the remote repository:
git push -u origin master
This will push the code to the branch named master and attempt to set it as the default branch of the remote repository. If you need to create a new branch, replace master with another branch name.
8. You have now successfully configured the Git environment and can use Git for version control and collaboration in this directory. Make sure to commit, pull, and push regularly to keep the codebase in sync and stable.
Note that the above steps provide only a basic Git environment setup. Depending on your specific needs and preferences, you may need additional configuration, such as setting up SSH keys for authentication.