GitHub Manual
GitHub Manual
Git:
Git allows you to keep track of changes in your code over time, including who made the
changes and why.
Git makes it easy to work on different features or fixes by creating separate branches,
then merging them back into the main project when ready.
Git is typically used via the command line (CLI), though there are graphical interfaces
available.
Use Case:
You would use Git to manage versions of your code on your local machine, enabling you to:
Track changes over time.
Revert back to a previous state if something breaks.
Collaborate with others without overwriting each other's work.
GitHub:
GitHub is a web-based platform built on top of Git, providing a collaborative
environment for storing, sharing, and managing Git repositories in the cloud.
Developers can explore public repositories, fork projects, and contribute to open-source
software.
Common GitHub Actions:
Push to GitHub: You can push your local Git repository to GitHub, making it available
online.
Pull Requests: Developers propose changes by creating pull requests, allowing team
members to review, discuss, and merge changes into the main branch.
Forking: You can copy someone else's repository into your own GitHub account to make
changes or contribute.
10. After Login you should click on some options which I already choosen.
11. Choose any two options and click on Continue button.
23. Now you can see the below your account is sign in with vscode.
24. Configure GitHub
Open Vscode Terminal and enter the following commands.
git config --global user.name “user-name”
In my case I replace user-name with “bilal-case”
25. Create a folder named as GitHub Demo and open this folder on Vscode.
26. First you need to initialize a repo. Enter a command git init.
27. Write a simple C++ program to print Sir Syed Case Institute of Technology
Islamabad.
28. Enter command git status to display the state of the code.
29. Enter command git add . to add all the files.
37. If you want to rename the branch, enter git branch -M (branch name).
38. Now push the code on GitHub. Enter command git push -u origin (branch name).
-u means set upstream (if you want to work on a project for long time).
Click on Authorize git-ecosystem shown below.
The picture below shows that your code is pushed to the main branch.
39. After completing the previous steps, go to GitHub and refresh the page.
40. I want to create a new README.md file. Repeat steps 29 to 32.
git add .
git commit -m “add message”
git push
Summary:
Commands Use
git init Initializes a new Git repository in your
project folder.
git add [file-Name] Adds changes (new files or edits) to the
staging area, preparing them for a commit.
git commit -m "[message]" Saves your changes to the repository with a
message describing what you did.
git status Shows the current state of your working
directory, including changes and files not
yet committed.
git push Sends your committed changes to a remote
repository (like GitHub).
git branch Lists all the branches in your repository or
creates a new branch.