![]()
In this blog you will be going to learn all the important commands in this Github crash course that 90% of the Data Scientist used in their day to day life.
How to upload any file to Github
The first commands helps us to initialize the git in your project
git init

The second helps you to
git add .

The third commands help you to commit all the files in the project.
git commit -m "Initial commit"

The fourth command
git branch -M main
git remote add origin https://github.com/<username>/<repository>.git

Then push the Github to the main branch
git push -u origin main
Now it will ask you to login into your Github account.

One you login it will upload all the files in your Github.

Some common problems while uploading
Problem 1 – If you are uploading the secret Key (.env file) along with the Github it will through you the error


In that case, what you have to do is create a .gitignore file which will exclude your .env file. Then, you can safely upload the project to GitHub. Below is the .gitignore file
# Exclude environment files
.env
.env.local
.env.*.local
Now delete the .git folder and again run all these commands
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/DataSpoof/demos.git
git push origin main --force
Note- If you want to store secret then you have to use Github secret. Then create a secret variable

Changing the branch
This command will help you to create a branch.
git branch branch-name
If you want to create a branch and switch
git checkout -b branch-name
Stashing
Stashing means saving your uncommitted changes temporarily so you can switch branches or pull code without losing your work.
Example Use Case
You’re working on a file and suddenly need to switch to another branch:
- ❌ You cannot switch because you have uncommitted changes
- ✔ So you stash them
Practical
I have this index.html

I have done some changes in the index.html

After this you want to temporarily save the file (stash it) and move to the other work, The command for this given below.
git stash push -m "stash index file" index.html

If you want to list all the stash present you can use this command
git stash list

If you want to see the details of the stash you can use this command

After this add the changes to the html file and then commit out
git add index.html
git commit -m "Applied stash changes"
If you want to clear the last one you can use pop command if you want to clear all you can use the clear command.
git stash pop
git stash clear
git stash drop stash@{0}
Conclusion
In this blog, all the major concepts of Github is covered.
If you like the article and would like to support me, make sure to:
👏 Like for this article and subscribe to our newsletter
📰 View more content on my DataSpoof website
🔔 Follow Me: LinkedIn| Youtube | Instagram | Twitter