Difference between Git and Github?
Git
:-Git
is an version control tool
Github
:- SomewhatGithub
is a web-based web hosting web service
Download
Download git from Git
git config
configuring user information used in all local repositories
git config --global user.name[firstname lastname]
git init
git init
is used to initialize the git in our project it generates a folder with the name.git
which stores all the information about the git stage and commits
git remote
git remote -v
is used to get remote access for theGithub
repository
git status
git status
is used to check the status of our project, it helps us to track the stage/unstaged file/folder in the project
git add
git add filename
is used to add a particular file to stage and then to commit it in ourGithub
repositoryanother way
git add .
is used to add all the unstaged files to the stage so that we can commit them all at once
git commit
is used to commit all the staged files and folders
another way
git commit -am "message"
is used to stage and commit in single command
git log
git log
is used to check all the logs meaning it helps us to track all the commits by showing the history of the commit done in the project, it shows details like commit hash(SHA), time, date as well as the message with the commit
git rm -cached
git rm -cached
is used to unstaged all the stage files and folders meaning it helps us with removing all the files and folders from the stageanother way
git rm -cached filename
is used to remove a particular file from the stage
git branch
git branch branch name
it is use to create a new branch in ourGithub
repository
git checkout
git checkout branch name
it is uses to change / switch from one branch to another
git push
git push -u origin master
is used to push the commit to master branchanother way
git push origin branch name
is used to push from origin to a banch
git merge
git merge -am "message"
is used to merge from one branch to other branch for Example ( main to master )
git reset
git reset -hard origin/master
is used to reset to last push commit
git pull
git pull
is used to pull the files and folder from remote repository to local
how to revert back to the previous commit?
Step 1:
git log
use the git log command to see all the commits and copy the hash(SHA) of the commit you want to revert to.
click q to exit the window
Step 2:
git reset --hard paste the hash(SHA) you want to revert to
Step 3:
git push -f
use this command to push the revert hash(SHA) so that your GitHub repository can get reset to that git commit