Upload files to Github - a comprehensive guide
Published: 2023-02-16 17:08:23

You just finished a project on your local PC. You are looking for a place to keep it so that you can access it anywhere and anytime or you just started a new project and you will be developing over a long time with some of your friends but you need to make it accessible to them, Hold on this article is for you.
 
Over the years, GitHub has been the most popular internet hosting service for version control using Git. GitHub makes it easy for you to store your files, track changes made to your files and collaborate on software projects. Github also serves as a portfolio site where developers can showcase their work, ask others to review it and work on open-source projects. So I'm sure You would have known by now that using GitHub is a good idea for you.

In this article, I will be guiding you on how you can setup Git on your PC and start loading files to your GitHub account from your local computer. 

**Article Summary:**


- [Create a GitHub account](#create-a-github-account)
    
- [Download and Setup Git
    ](#download-and-install-git)

- [Upload files on Github](#upload-files-on-github)
- [Other Git commands you'll need](#other-git-commands-you-need)




## **Create a Github account**

Before you can start using Git and GitHub, the first thing is to download a GitHub account. Go to your browser and search GitHub or click this link [github.com
](https://github.com) 
Click on the signup button and follow the steps to finish setting up your account. Now that you have an account, You need to create a new repository. A Git repository helps to save and track all the changes made to your files. 
To create a new repository, click on repositories and click on new. You can decide to make the repository private or public. Public, if you want others to have access to it and private, if you want to keep the files to yourself. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b6r42ebq3tcty7nxd91l.jpg)

**Extra tips:** Choose a file name that gives an intuition about what your project is about e.g myPortfolioWebsite, LearningApp, Hotel_landing_page, etc also include a readme file where you write a good description of your project.

## **Download and Install Git**

Before you can start using Git, you need it installed on your pc. There are different ways to get git installed on your pc but I will be explaining some of the easiest ways.

**Window Users**
Download the [latest version](https://git-scm.com/downloads) of Git and choose either the 32-bit or 64-bit version depending on your PC (check your PC's information). 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r8e9mujx8bg6knfre4kn.jpg)
Install the downloaded file. Once installed, launch the Git bash and finish the setup.
You can read more on installing Git on windows [here](https://phoenixnap.com/kb/how-to-install-git-windows)

**Mac Users**
For mac users, the easiest way is probably using a binary installer. Just go to [https://git-scm.com/download/mac](https://git-scm.com/download/mac) and choose the binary installer option, download the installer, and run it on your mac

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fj248s5tc2eltluxghg8.jpg)

**Linux Users**
Linux distribution comes with a package management tool that makes it simple to install git
From your shell, install Git using:
```linux
$ sudo apt install git-all 
```

Verify the installation was successful by typing:
```git
$ git --version 
```


### **Configure Git**
Now that you have successfully installed Git on your system, You need to do some setup to customize your experience using Git.
Git Email and username: replace 'savviesammie' with your GitHub username 

```git
$ git config --global user.name "savviesammie"
```
```git
$ git config --global user.email "savviesammie@gmail.com"
```


### **Upload Files on GitHub**
Remember the repository You created at the beginning of the tutorial? You will be cloning it on your pc and interacting with Git from your terminal. So go to your terminal and follow the tutorial.
cloning a repository means you are copying the repository from GitHub to your local computer.

**Step 1:** Clone the repository
Go to the repository you created on GitHub, click the green "code" button, and copy the link to your repository from the drop-down.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d1ika1rri9hvxq8q00na.jpg)

**Step 2:** Go to your terminal and type
git clone <repository URL>

```git
$ git clone https://github.com/savvieSammie/password_manager.git
```
Replace the "repository url" with the link you copied.
make sure you have a good internet connection on your pc as you will be downloading the directory. 

**Step 3:** Put your files in the cloned repository:
Open the empty directory and add the files that you want to upload. Say for example, you have written some codes using a text editor and you have the file saved on your pc, transfer the file to the directory you cloned from GitHub and make sure to Confirm the list of files present 

**Step 4:** Git add
Add the files to Git's staging area by typing

```git
$ git add .
```

**Step 5:** Commit the files to Git by using the git commit command
```git
$ git commit -m "some message"
```

replacing "some message" with a short description of the changes you made to the first. In your case, since it's the first time, you can just write "first commit"

**Step 6:** Set your remote repository
Earlier in step 1, you copied the url to your remote repository. You need it here to setup your remote repository, use the command 
$ git remote add origin <repository url>

for example: 

```git
 git remote add origin https://github.com/savvieSammie/password_manager.git
```
**Step 7:** Git to push
push those files to your GitHub by using the command
$ git push <remote> <branch>

```git
$ git push -u origin master
```
The origin is your default remote repository name and the '-u' flag is upstream.
You will be prompted to fill in your GitHub username and password.

Now you can go to GitHub on your web browser, you will see the changes reflected.

### **Other Git Commands you need**
**git init** - Initialize local a new repository
**git status** -shows what you have in your staging area
**git add <file>** - adds files and folders to the staging area
**git diff** - compare and understand changes made to your files
**git log** -  is used to view the log of the project's history.
**git push** - Takes a local repository and pushes to a remote repository (Github).
**git show** - to show the details of a specific commit
**git pull** - Pull latest changes from remote repository
**git clone **- Clone repo from GitHub

To view the official Git cheatsheet from Github, click [Git cheat sheet](https://education.github.com/git-cheat-sheet-education.pdf) 

### **Conclusion**

In this article, I have shown you how to create a GitHub account, setup Git on your PC and how to upload files from your local computer to GitHub. I also included some Git commands that you'll need. 
By now, you should have Git running on your pc and also you have gained basic working knowledge of Git and Github.

Say hi to me on Twitter [@Sammie_savvie](https://twitter.com/Sammie_savvie?t=SB6V1YTT6uwn1CwrvFoFaw&s=09)