Getting your folder or file to github can be a bit of an off vibe due to the many steps especially if it's your first commit, but getting these steps right will make it easy for the other folders or files you will push afterwards.Let’s dive in
CREATING A LOCAL FOLDER
Depending on the OS you are using you can use Git Bash or the Terminal. For Linux which is what I am using I will use the Terminal
First Step
Start by creating a folder in the terminal:
mkdir your project folder name.
then change directory:
cd ~/to the folder you have just created
Now we need to format our folder by creating a few files inside it
- Data file
- README.md
- code file if you will be using code.
To check if you have created these files inside your folder: run:,
ls
This calls out all the files that are inside your folder. Let's tackle the files we have just added.
Data Folder
Run command:
mkdir data
This creates a data folder. This is where you will add or copy your data e.g Excel or CSV files that you will be using to run your analysis or your project.
README.md
Run command:
touch README.md
This where you will give an overview of your work, the reason you are doing the analysis,how you collected your data,the tools you used to run the analysis..Basically README.md is a file that guides anyone who goes through your analysis or project on the steps you took while doing your analysis or project.Think of it as the introduction at the start of your favourite book or novel.
To write all of this you will run the command
echo "#give your project a name or describe your project" >README.md
README.md uses markdown language reason for the # at the beginning of the quotation.When writing the headings or subtitles use capital letters or proper style. For subtitles you need to add two ## at the beginning.
If you want to write more content without overwriting what you have previously written inside the README.md file you will need to use double greater signs(>>) at the end of the quotation,run:
echo #your message” >>README.md
Run
cat README.md
To check what you have written. If you made an error
Run
nano README.md - then edit
To save your changes - Ctrl+O then enter, Ctrl+X to exit.
Pushing Folder Or File To GitHub
After creating our folder and files, we need to commit and push them to GiHhub.
For this process, you will need to have set up your github account plus your SSH key.
The first step we need to do is run
git init
This initializes Git to start tracking all changes in the current folder.While running this command make sure you are inside the folder you want to commit.so change the directory into the folder or file you want to commit.
second step, run:
git status
This shows all changes which were not committed yet.
Third step run:
git add .
This picks all the files in the folder.If you don't want to commit the whole folder you can run:
git add (the name of the file inside your folder that you want to commit)
Fourth step, run:
git commit -m (add message here of what you are committing or the name of the folder you are committing)
Before pushing your folder, confirm if you are on the main branch by running:
git branch
if it does not show main switch to main by running
git checkout main
After you have successfully run all the steps above, now it's time to push your folder to github.
Open your github account, navigate to the repository on your far left, click on New Repository. Name your repository, this could be the same name as your folder then give a brief clear description of your project, then press Create Repository.
Note: do not add README.md since we already created one.
Once it has been created Copy the SSH URL..
After copying the URL go back to the terminal and Run:
git remote add origin < your copied URL>
(this is where you paste the URL you copied from Github )
then Run:
git push -u origin main
A prompt may appear if your SSH key has a passphrase, enter the passphrase.
This is the passphrase you set when you were generating your ssh key.
Go back and refresh your github page this should make the changes reflect on your github page.
Following these steps without skipping will get your project fully running on GitHhub :)
Top comments (0)