git config --global user.name=“Your Name”
Set the name that will be attached to your commits and tags.
git config --global user.email “firstname.lastname@example.org”
Set the e-mail address that will be attached to your commits and tags.
To view the configuration:
git config --global user.email git config --global user.name
Create a project on your computer:
to initialize empty Git repository inside your project folder:
to view files inside your project folder:
It will show list of files.
To view hidden files(.extension-file) inside project folder.
To create new/empty file.
It allows us to see the tracked, untracked files and changes.
Add a particular file to the staging area.
git add [filename]
git add .
Create a new commit from changes added to the staging area.
The commit must have a message!
git commit -m [message]
It shows the list of commits of current branch.
To unstage your file/Removing changes from staging area
git restore --staged [filename]
To remove a commit from the history of a project.
git reset [commit hascode]
Git has an area called the stash where you can temporarily store a snapshot of your changes without committing to the repository.
Apply stored stash content into working directory, and clear stash.
git stash pop
Delete a specific stash from all your previous stashes.
git stash drop
Connect remote repository to local repository by using this command
git remote add origin [url]
pushing local changes to remote repository:
git push origin master/ git push -u origin master
A fork is a rough copy of a repository. Generally forking a repository allows us to experiment on the project without affecting the original project
Reason for forking the project
1.propose changes to someone else's project
2.Use an existing project as a starting point.
Cloning the forked project to local
git clone [url]
After cloning you will be able to see clone project inside your project folder.
upstream : upstream generally refers to the original repository that you have forked from other git repositories.
git remote add upstream [url]
For viewing both url (origin and upstream):
git remote -v
Create new branch:
git branch [branchname]
The git checkout command switched branches or restores working tree files. It allows switching between multiple branches in a single repository.
git checkout [branchname]
It shows the list of branches.
Why we create new branch?
=>Because we want to open a new pull request and we can only open a new pull request with a new branch. In simple language one pull request means one branch.
Never commit on main branch and create our pull request first.
That's a wrap! You've made it to the end of the blog!
link mentioned below for other blog about the introduction of the git.
Introduction to Git
Top comments (1)