Getting started with GitHub
Source: Dev.to
Setting up Git locally
- Configure Git to connect to your remote account.
- Linux/macOS: run the commands in a terminal.
- Windows: use Git Bash after installation.
Verify the configuration with:
git config --global --list
git config --global user.name "Name"
git config --global user.email "email-address"
- Navigate to your local project directory and initialize Git:
git init
- Create a
README.mdfile (or any other file, e.g.,users.py):
touch README.md
The README.md file describes the project and how to use it.
Pushing Code
- After working on your project, add changes to the staging area:
git add .
- Commit the changes with a concise message:
git commit -m "signup function"
- Push the code to the remote repository:
git push -u origin main
Note: Without committing, changes remain only in the local repository. The first push may prompt for authentication; set up SSH keys or a Personal Access Token for HTTPS.
Pulling Updated Code from GitHub
- Check the status of your repository to ensure no uncommitted changes:
git status
- Pull the latest changes (equivalent to
git fetchfollowed by a merge):
git pull