Beginner's Guide: Git

created with html
Prerequisites
- A computer with internet access
- Basic command line knowledge
- GitHub account (create one at github.com)
- GitLab account (create one at gitlab.com)
Installing git
Windows
- Download git from git-scm.com
- Run the installer with default settings.
- Verify installation by opening Command Prompt or PowerShell:
git --version
macOS
Using Homebrew:
brew install git
Linux (Ubuntu/Debian)
sudo apt update
sudo apt install git
Initial git configuration
Set up your identity:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Set default branch name:
git config --global init.defaultBranch main
Connecting to GitHub
Method 1: SSH Authentication (Recommended)
Generate SSH key (if you don't have one):
ssh-keygen -t ed25519 -C "[email protected]"
Start SSH agent:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
Copy your SSH public key:
- Windows:
cat ~/.ssh/id_ed25519.pub | clip
- macOS:
pbcopy < ~/.ssh/id_ed25519.pub
- Linux:
cat ~/.ssh/id_ed25519.pub
- Windows:
Add SSH key to GitHub:
- Go to GitHub ===> Settings ===> SSH and GPG keys
- Click "New SSH key"
- Paste your key and save
- Test connection:
ssh -T [email protected]
Method 2: Personal Access Token (PAT)
- Generate PAT on GitHub:
- Go to GitHub ===> Settings ===> Developer settings ===> Personal access tokens
- Click "Generate new token (classic)"
- Select required scopes (at minimum: repo, read:org)
- Copy the generated token
Run Git Command:
When you perform a Git operation (likegit push
orgit pull
), Git will prompt you for your username and password.Enter Your GitHub Username:
For the username, enter your GitHub username as usual.Use the Personal Access Token (PAT) as Your Password:
For the password, instead of your GitHub account password, paste the Personal Access Token (PAT) that you copied from GitHub.
Important: Your token acts as a password, so don’t share it. You’ll need to use it for Git operations that require authentication.
Store credentials (Windows):
git config --global credential.helper wincred
On macOS/Linux:
git config --global credential.helper store
Connecting to GitLab
Method 1: SSH Authentication
same as github just to test connection use ssh -T [email protected]
Method 2: Personal Access Token
- Generate PAT on GitLab:
- Go to GitLab → Preferences → Access Tokens
- Create a token with necessary scopes
- Copy the generated token
the next steps is same to github
Git basic vommands withrExplanations
git init
Initializes a new Git repository in the current directory. This command creates a.git
directory, where Git stores all the repository's configuration and metadata, making the directory a Git repository.
git add .
Stages all the changes made in the working directory (files that have been modified, added, or deleted) for the next commit. The period (.
) represents all the files in the current directory and its subdirectories.
git status
displays the current state of the repository. It shows which changes have been staged, which haven't, and which files aren't being tracked by git. this helps keep track of the changes before committing them.
git commit -m 'message-of-the-commit'
Commits the staged changes to the local repository, adding a descriptive message that explains what was changed in this commit. The-m
flag is followed by the message in quotes.
git remote add <name> <url>
adds a new remote repository to your local Git repository. The<name>
is typically a shorthand for the URL (e.g.,origin
), and<url>
is the actual URL of the remote repository (e.g., GitHub). This allows you to push and pull changes between local and remote repositories.
git checkout -b develop
Creates and switches to a new branch nameddevelop
. The-b
flag combines the creation and the checkout of the branch in one command, branches allow you to work on separate features or fixes without affecting the main project.
git push --set-upstream origin develop
Pushes the localdevelop
branch to the remote repository (origin
), the--set-upstream
option sets the remote branch as the default upstream for the local branch, meaning you can usegit push
andgit pull
without specifying the remote or branch name every time.
These are some of the most commonly used Git commands, essential for version control and collaboration in software development.
This is a beginner Git guide. Let's talk about how Git is used in professional work. In my professional experience, I have worked with two methodologies at different companies.
The first methodology is GitFlow Workflow. GitFlow is a branching model that defines a strict branching strategy designed around project releases.
The second methodology is Single Branch (Trunk-Based Development). This is the opposite of GitFlow, where developers commit primarily to a single branch (usually main or master).
the repo that i pushed https://github.com/Omar-ABDELKEFI/GuideGit
it's just html page if you opened you will see somthing like frist gif :p
additionalresources
I'm Kafio, a mentor for the Technology and Development Club. I hope to join our club, where there are interesting rewards and plenty of information to share between us.
Additional Info About the Tech Club
The Tech Club focuses on technology and development, including:
Web & Mobile Development
AI & Machine Learning
DevOps & Cloud Technologies
Blockchain & Decentralized Apps
Open-source Contributions
Graphic Design & UI/UX
The club is open to everyone, and even if you're not a developer, you can still share ideas, give feedback, and collaborate on projects.
For more details about the club, check out the post: *A New Era of Learning on Steemit: Join the Technology and Development Club.
cc: @mohammadfaisal , @alejos7ven
Upvoted! Thank you for supporting witness @jswit.
This guide is really impressive that covering everything from he basic installation of Git to advanced workflows like GitFlow based development. Your step-by-step and detailed instructions for set up the SSH keys and PATs on both GitHub and GitLab are valuable, especially for beginners and its transformation method into professional development environments is good. The addition of practical Git commands and detail explanations of each operation really version control. I also appreciate the nod to best practices for set up GitHub like credentials storage and the way of securing the key management.