Monthly Archives: June 2020

Git – memory helper (Work in progress)

This is a very simple post about some commands I wanted to remember, especially the ones required to install and configure Git on a new computer. I will keep this post updated in the future, so feel free to come again from time to time.

How to push your project code to your new Git server on Windows

First, you need to install Git on your Windows machine, I’m using chocolatey for that task:

choco install git

Then we need to add our remote repository with the following commands:

# Move to your project folder
cd D:\mydir

# Initialize Git
git init

# Add a connection to your remote Git server
git remote add my-app git@10.0.0.77:my-app.git

Now, we need to push the content over the remote repo. Before doing that, we need to add our project’s files to the local repo, them commit those changes and push the whole thing eventually:

# Add all our projects files
git add .

# Commit those new files to the local repo, the message is mandatory
git commit -m 'Initial commit'

# Finally, push everything to the remote Git
git push my-app master

How to deploy Git “client” on Linux

Install the package, here for Ubuntu:

apt get install git

Go to the folder you want, then run the following commands:

cd /var/www/mydir

# Initialize Git
git init

# Add a connection to your remote Git server
git remote add my-app git@10.0.0.77:my-app.git

# Pull the data from the master branch of the remote Git server
git pull my-app master