What is Git?
Git is a version control system that allows you to track changes in your files and collaborate with others.
What is GitHub?
GitHub is a cloud-based hosting service that lets you manage Git repositories, collaborate on code, and use features like issue tracking, pull requests, and more.
Create an account on GitHub
Create tokens for repository access
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
Store github token in git
https://stackoverflow.com/questions/35942754/how-can-i-save-username-and-password-in-git
Installing Git:
For Windows 🏠:
Download from git-scm.com and run the installer.
For macOS 🍏:
Use Homebrew with the command:
brew install git
For Linux 🐧:
Install via your package manager, e.g., for Debian/Ubuntu:
sudo apt-get install git
Configuring Git:
Set your username and email, which will be associated with your commits:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
git config --list
- Go to GitHub and log in.
- Click on the "New" icon at the top-right corner to create a new repository.
- Name your repository and make it either public or private.
- Click on <> Code in the top-right corner to copy the https link for cloning
Navigate to the directory where you want your project to be in the terminal:
cd /path/to/your/project
Clone your repository to directory
git clone https://github.com/vilmacanfjorden/github_tutorial.git
Make sure you got the repository and cd into it
ls -l
cd test_repo
Add a file to your repository:
echo "print('Hello World')" > test.py
git status
when using git status it should look something like this:

Add changes to the staging area:
git add test.py
git status
Commit the changes:
git commit -m "Initial commit"
git status
Push you updates to your repository on GitHub
git push
Go to your repository on github.com Go to your README.md and edit, write something informative on how to use your code for example:
Commit the changes by clicking on Commit changes in the top-right corner

Go to your teminal again and make sure you are in the repository and pull the latest changes:
git pull
git status
Now you should have the latest README updated locally as well.
-
Commit Often: Keep commits small and focused.
-
Use Descriptive Commit Messages: Clearly explain what changes were made and why.
-
Pull Before You Push: Always pull the latest changes before pushing to avoid conflicts.
-
Official Git Documentation: (https://git-scm.com/doc)
-
GitHub Learning Lab: (https://docs.github.com/en/get-started/start-your-journey/git-and-github-learning-resources)
Click to expand!
Create a New Branch:
git branch new-feature
Switch to the New Branch:
git checkout new-feature
Switch back to the main branch:
git checkout main
Merge the branch:
git merge new-feature
Undo a Commit:
git revert <commit_hash>
Remove a File from the Staging Area:
git reset HEAD <file>



