Basic Git Commands for Creating new branch and Pull Request
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 add .
We have different methods for adding.
- “git add .” This will add all the untracked files
- “git add lib/Pages/Auth/login.dart” This will only add “lib/Pages/Auth/login.dart” file
- “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 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”
git commit -m “message”
After switching to the new branch. And committing all the untracked files we are all ready to push the code.
Now we can compare the changes and make the pull Request.
We can see this
Now we can compare the branches and create a new 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.