Git Setup
Installation + Initial Setup
- check if git is installed
git --version
, otherwisesudo apt install git-all
git config --global user.name "YOUR_GITHUB_USERNAME"
- verify configuration
git config --global user.name
git config --global user.email "YOUR_GITHUB_EMAIL"
- generate ssh key
ssh-keygen -t rsa -b 4096 -C "YOUR_GITHUB_EMAIL"
- add public key (
cat /home/YOUR_USERNAME/.ssh/NAME_OF_THE_KEY.pub
) to GitHub settings - add ssh key to agent
eval "$(ssh-agent -s)"
vim /home/YOUR_USERNAME/.ssh/config
and addHost github.com HostName github.com IgnoreUnknown UseKeychain AddKeysToAgent yes IdentityFile ~/.ssh/NAME_OF_THE_KEY
ssh-add ~/.ssh/NAME_OF_THE_KEY
- test ssh connection
ssh -T git@github.com
, if answer is YES, it's working - then you can clone a repo to your server (
git clone git@github.com/YOUR_GITHUB_USERNAME:YOUR_GITHUB_REPO.git
) or you can create new repo on your local machine
Create New Git Repositary and Publish it on GitHub
- create a repo on GitHub
- move to your project directory
git init
- create .gitignore, readme, django project
- add everything in git
git add .
orgit status
andgit add FILE_YOU_WANT_TO_ADD
- create commit message
git commit -m "initial"
git remote add origin YOUR_SSH_URL
(git@github.com:YOUR_GH_USERNAME/YOUR_GH_REPO_NAME.git)- verify the new remote URL
git remote -v
- push files to master branch on GitHub
git push -u origin master
Resources:
➡️https://help.github.com/en/articles/setting-your-username-in-git
➡️https://help.github.com/en/articles/setting-your-commit-email-address-in-git
➡️https://help.github.com/en/articles/which-remote-url-should-i-use#cloning-with-ssh-urls
➡️https://help.github.com/en/articles/connecting-to-github-with-ssh
➡️https://help.github.com/en/articles/testing-your-ssh-connection
➡️https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent