on
Git has been Got
GIT is a tracking system of codes for web developer or software engineer made by the creator of Linux. It includes multiple directories that continuously changes as codes are added throughout website development. Git also tracks the performance of the codes on the stored data. To use GIT we have to use the terminal.
So, if you are new to git, too, follow the following few steps below to get familiar in making changes to the code base, making a pull request, and merging code into the master branch.
STEP - 1 : Install git and create a GitHub account
The first thing anyone who is beginning GIT has to install git and create a free GitHub account.
STEP - 2 : Create a local GIT repository
When creating a new project on your machine using git, you’ll first have to create a new repository.
Now, open a terminal and move to where you want to place the project on your local machine using the cd
(change directory) command. Then, using git init
command initialize a git repository in the main folder or the root folder.
STEP - 3 : Add a new file to the repository or modify file in the existing folder itself
Once you’ve added a file or modified files in a folder containing a git repository, GIT will notice that changes have been made inside the repository but it will not officially keep track of the file.
After creating the new file, you can use the git status
command to see which files is being modified or added.
STEP - 4 : Add a file to GIT
Add a file to GIT using the git add
command.
STEP - 5 : Create a commit
It’s time to create first commit!!
Run the command git commit -m " Your message. "
The message at the end of the commit should be something related to what you have done in the file or added some file. That makes the other web developer who see your commit understand your commit and code more clear.
STEP - 6 : Push all the changes to the GitHub Account
git push origin
command will push changes from all local branches to the master branch.
Concept of Branching in GIT
Branches are used to develop features in a website far away from each other. The master branch is the “default” branch when developer create a repository. Developer uses other branches for the development and merge them back to the master branch upon completion.
Main commands used in the Branching
-
To create a new branch named “branch1” and switch to it we use -
git checkout -b branch1
command. -
To switch back to master we use -
git checkout master
command. -
To delete a branch we use -
git branch -d branch1
-
Remember, a branch is not available to others unless we push the branch to our remote repository. To push the branch to remote repository we use -
git push origin <branch>