Git Overview

Git Setup

My default installation on linux:

yum install git -y

git config --global user.name "USERNAME"
git config --global user.email "EMAIL"
git config --global color.ui true
git config --global format.pretty oneline
git config --global push.default simple

ssh-keygen -t rsa -b 4096 -C "EMAIL" -P '' -f ~/.ssh/git
cat ~/.ssh/git.pub
# Add to SSH Keys in your github/gitlab/gitea account

echo "" >> ~/.ssh/config
echo "Host DOMAIN" >> ~/.ssh/config
echo "User git" >> ~/.ssh/config
echo "IdentityFile ~/.ssh/git" >> ~/.ssh/config
echo "IdentitiesOnly yes" >> ~/.ssh/config

Commands

Initializing a repo

A new/empty repo:

git init
git remote add origin user@gitlab.server.com:repo/path
# After First Push
git branch --set-upstream-to origin/master

Clone a repo to the current dir:

git clone user@gitlab.server.com:repo/path .
git branch --set-upstream-to origin/master

Upload Changes

git add .
git commit -m "Commit Message"
git push

Download Changes

git pull

Work with branches

# Create Branch
git checkout -b feature_x
# Switch Branch
git checkout master
# Delete Branch
git branch -d feature_x

Retrieved from "$'"1"