Git tutorial¶

What is Git and Github,gitlab,etc¶
Git is a version control software that keep track of chages that hapen acrossa set of files while github,gitlab are web-platforms that hosts Git repositories online. *It let you store files,codes in the cloud. collaborate and manage projects using git through a website interface*.
Installing git on Windows¶
Download the Git from git official site , the download will start automatically
Install the file click next until you reach to where it asks to Add to PATH and Check the box to add to PATH.
Open Command Prompt by pressing Windows key+R, the type cmd and press Enter.
In the black terminal, type git - -version to checck if it is installed

Basic Git configartion¶

To confirm;¶

C:\Users\Wuod Awuor>git config –global –list
SSH Keys.¶
SSH keys allow you to establish a secure connection between your computer and GitLab. SSH fingerprints verify that the client is connecting to the correct host.
SSH stands for Secure Shell.
An SSH key is a pair of cryptographic keys (public + private) that lets your computer securely communicate with a server without typing your password every time.
In GitHub, it’s used to authenticate your computer with GitHub securely

Generating SSH Key¶
- Open Git Bash by right-clicking your folder and selecting “Open Git Bash Here”. This will launch the terminal in that folder, which will be used to generate your SSH key.


- Run the ssh-keygen command:
ssh-keygen -t ed25519 -C"your_email@example.com"
Replace “charliea@gml.com” with the email associated with your GitHub account.
Notes:
t ed25519→ type of key (modern and secure)C→ adds a comment to help identify the key
Tips;
working on a shared project/collaboration on a project;
- Each team member must have a Git web service account (e.g., GitHub, GitLab, Bitbucket).
- One team member creates the main repository (the “master” or “main” branch).
- Other members clone the repository to their local machines to work on it.
- Making changes:
- You can work directly on the main branch (not recommended for beginners)
- Or, better, create your own branch to make changes safely
- Update and review:
- Push your branch to the remote repository
- The team can review your changes
- Merge changes: After approval, the branch can be merged into the main branch
Cloning Repository¶
To collaborate on a project, one person first creates a repository (the master/main branch). Other team members can then clone the repository to their local computers.
Collaborators can make changes either:
Directly on the master branch
Or on separate branches, where updates can be tested and verified
Once the changes are reviewed and approved, the branches can be merged back into the master branch to update the main project.

Basic git commands¶
Here are some basic Git commands I’ll use in the terminal:
git status: Shows which files have been changed, added, or deleted in the project.git add .: Add all changes to the staging area.git commit -m "assignment1 commit msg": Commit assigmnet changes with a message.git push: Push assigment changes to the repository.git pull: Pull the latest changes from the remote repository.
Git Command in GUI (VSCode)¶

The image above shows stages for pushing to your repository in GUI: 1. Open Source Control – Click the Source Control tab in your editor. 2. Stage Changes – Select the files you want to commit and click Stage.Also you can stage evrthing if you are sure of the size of your files. 3. Commit Changes – Enter a commit message and click Commit. 4. Sync & Push – Finally, click Sync (or Push) to upload your changes to the remote repository, as shown in the image below.

Sync and Push means your changes have been uploaded to the public repository.
