Git is a version control system that allows tracking changes to code. GitHub is a platform that uses Git to manage codebases in the cloud. Git allows reverting code to previous versions if new changes break an application. It also facilitates collaboration through features like branching and merging. The document provides instructions for initializing a Git repository, committing and pushing changes to GitHub, creating and switching branches, and making pull requests to contribute code. It emphasizes documenting projects with a high-quality README to showcase work and help others understand and use the codebase.
3. Git is a version-control-system and GitHub is a cloud platform which
uses git to manage your codebase.
Let’s say you’ve added a new feature in your app and it breaks the
application for some reason. Now you want to go back in the past
and get access to the previous version of your code where the app is
running smoothly.
This can be done by using Git! Also collaborations can be achieved
via Git and GitHub :’)
4. Getting Started
repository - The folder where you store your all
code files
Stuck anywhere in a repo?
git status #-will show you the status of your
repository
5. Start with a git project from
scratch
initializes a git repo in the folder-
git init
commit your changes-
git add . # add files to the staging area
git commit -m "some commit message" # commit the changes to the version
git add?
it basically adds all of your specified files into a staging area where the changes can be
saved.
revert this step - remove added files to the staging area
git commit?
it takes a photo of all the staged files and add this snapshot/version in the history.
6. Start with a git project from
scratch
push to github?
using git stash stash the changes
git stash
this’ll put all the untracked and tracked changes to a stash area
get back stashed changes
git stash pop
will bring back the changes clear the stash
git stash clear
7. How to check all the versions
of your code?
log all the commits / versions
git log
to exit the log just type :q and hit enter
go to a specific commit in history
git revert commit_id
get the commit_id from git log
8. Getting started with Github
pip install
<requirement
r> [package-index-
ns] ...python -m
pip
all [options] -r
quirements file> [package-
x-options] ...python -m
[options] [-e] <vcs
thon -m
pip
local
ip
9. Getting Started with Github
initialize a repo (new)
here - https://github.com/new
link this github repo to your local git repo
get the git url
copy the url from the new repo or just grab the url from the chrome url box
link the repo
git remote add some_name url
some_name - the name to remote account accessing
url - the url you copied from get the git url
check all the remote repos attached
git remote -v
push the changes from your local to github
git push some_name branch_name
some_name - some_name - the name to remote account accessing
branch_name - the branch you are currently at
10. Git Branching
create a branch
git branch branch_name
go to a branch (branch_name)
git checkout branch_name
merge a branch
let’s say you have two branches - main and feature
you are in feature branch and you have to merge
feature in main
11. Git Branching
create a branch
git branch branch_name
go to a branch (branch_name)
git checkout branch_name
merge a branch
let’s say you have two branches - main and feature
you are in feature branch and you have to merge
feature in main
12. making a pull request (pr)
fork the repo from organization account to your account
docs - https://docs.github.com/en/get-started/quickstart/fork-a-repo clone your
repo locally git clone url
docs - https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-
repository
make a branch for pr
ref - create a branch with the feature name (it’s a convention)
commit and push your changes of the new branch to your account
commit changes - commit your changes
push to github - push the changes from your local to github
open github repo of your account and create a pr
docs - https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-
changes-to-your-work-with-pull-requests/creating-a-pull-request
13. To stand out
Make other’s life easy
Project title & description
Installation and run guides
How to understand / use the project
Credits / license
Badges
Contributing guidelines
Tests, if they exist
Why make a readme file / document your repo?
Makes a good impression of your project and account
things to include in a readme