Basic Git Commands for Creating new branch and Pull Request

Juned Raza
3 min readJun 8, 2021

--

In software engineering life every day we deal with at least one version control tool such as Git, Gitlab, Azure, etc. Mostly we use the inbuilt tool in VSCode, Android Studio, PyCharm for this purpose, but sometimes we need to use command-line access for this purpose let me explain some of the important Git commands.

git status

This command show all the local files that are currently tracked or untracked

git add .

This will add all the files which are edited so after this if we run “git status” we can see files are now tracked.

We have different methods for adding.

  1. “git add .” This will add all the untracked files
  2. “git add lib/Pages/Auth/login.dart” This will only add “lib/Pages/Auth/login.dart” file
  3. “git add — patch” This will help to add some part of the files. So It doesn't affect the whole file. After running this command other sub-commands pop-ups as follows.

It will ask one by one for all changes in all files. You can type:

i) “y” for adding the change.

ii) “n” ignoring the change.

iii) “q” for quitting.

iv) “a” for adding all changes.

v) “d” for ignoring all further changes. This one is helpful if the required part of the change is already added.

git reset

This will remove the added changes.

git branch

This shows available branches.

git checkout “ branch name”:

This one is to checkout to another branch. We can also use “ git checkout -b “new_branch” this will create “new_branch” and also checked out to “new_branch”

Crated new_branch2 and also switched.

git commit -m “message”

This command is to commit the changes with message

After switching to the new branch. And committing all the untracked files we are all ready to push the code.

git push:

Using this command commit is pushed to GitHub remote with new branch

Now we can compare the changes and make the pull Request.

We can see this

On Github Project we can see this

Now we can compare the branches and create a new pull request.

Add message and create pull request

I hope this one helped you creating a new branch and opening a Pull Request. If you like to connect with me connect on LinkedIn. Don’t forget to add some claps.

Thank You.

--

--

Juned Raza
Juned Raza

Written by Juned Raza

Flutter Developer, Andriod Application Developer, Django Developer ,Computer Engineering student at ZHCET, Aligarh Muslim University.

No responses yet