Quick Guide to Git and GitHub – Command Line (CLI)

In this guide I will cover some basic commands to configure Git and upload your project to GitHub using command line. macOS should already come with Git pre-installed, but just in case, follow this link to install it, Installing Git on Mac. If you are on Windows, you can get Git for Windows, or enable Windows Subsystem for Linux (WSL).

[topads][/topads]

Gives you the Git version

git --version

Add your name to Git configuration

git config --global user.name "Esau Silva"

Add your email to Git configuration

git config --global user.email esau@silva.com

Make an alias to checkout

git config --global alias.co checkout

Make an alias to create a branch

git config --global alias.br branch

Make an alias to commit

git config --global alias.ct commit

Make an alias to show the status

git config --global alias.st status

This will show all your Git configurations

git config --list

Before you start uploading your code to GitHut, you will need to create an account with GitHub, create a repository and generate an SSH key. Follow the following guide to create the SSH key Generating SSH Keys

Once you have created your account and generated the SSH Key, you are ready to start using GitHub

At this point, you will need to be at the root of your project

Initializes the repository

git init

Add all the files of your project to the staging area

git add .

If you want to see all the files that will be added to Git

git status

Commits your code to Git

git commit -m 'first project version'

Sets up GitHub as the origin for the master branch. Remember yo change <<username>> with your GitHub username, and <<repository_name>> with the name of the repository you created

git remote add origin git@github.com:<<username>>/<<repository_name>>

Finally push your project files to GitHub. Remember to always push the origin to master

git push -u origin master

[bottomads][/bottomads]

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.