Hamidreza Amini

Hamidreza Amini

JavaScript Engineer

  • Residence:
    Iran
  • City:
    Shiraz
  • Year of birth:
    1993

Languages

100%

Persian

70%

English


Coding

JavaScript

90%

TypeScript

90%

React

90%

NodeJs

70%

Web3.js

70%

React Native

40%

HTML, CSS, SASS

90%

C#, ASP.NET

70%


Knowledge
  • Linux (Ubuntu)
  • SOLID Principles
  • Redux, GatsbyJS
  • ExpressJs, PassportJs
  • MongoDb, Mongoose
  • Stylus, SASS, SCSS
  • GIT Version Control

Git flow for a forked repository, a practical solution

fork git flow

Having a git flow is a great idea for each developer who does not want to face with too much of conflicts. So read this post if you need a practical and useful git flow.

Forking

If you’ve been forked a repository from another repository, it’s recommended to run the following commands after cloning your forked repository:

git remote add upstream [base repository address]

git fetch upstream

Common Git Flow

This section is a common git flow for those repositories which is forked from another repository, and those which is not. So it doesn’t matter which one do you use. It’s recommended to follow the following git flow to decrease the potential risks.

Create new local branch

I recommend you to create a local branch for yourself and always coding in that branch:

# create a new local branch with your custom name, for example "working"'
git checkout -b working

Committing

When you need to commit your changes, you need to do the following commands in your local branch:

# if you have new files or folders
git add .

# if you are working on specific issue, it's better to mention your issue number in your comment with a hashtag before --> for example [#1]
git commit -am 'your-comment'

Merge & Rebase

If you reach a stable version and you need to merge your changes with the parent branch, follow the following flow:

  1. Checkout to your parent branch:
# if your parent branch is master
git checkout master
  1. Pull the latest changes:
# if you are working on a forked repository. Get the latest changes from parent repository
# if your main branch of your parent repository is master
git pull upstream master

# then
git pull
  1. Rebase your local branch:

a. After finishing the second step, if there was updates caused by your pulling, you should get back to your local branch and rebase it from its parent, if not, you can skip the third step:

git checkout working

git rebase master

b. After using rebase command, if you face with conflict(s), first of all you should resolve the conflicts and then do the following commands and repeat it again until you not facing with conflict(s) anymore:

git add .

git rebase --continue

c. Getting back to your parent branch:

git checkout master
  1. Merge & Push: Now you can merge your parent ( master ) branch with your local one and then push it to your git repository with following commands:
git merge working

git push

Create a merge request

If you use forking, after following the above flow in your forked repository, you should create a merge request in your repository panel, from your forked repository to the main one and wait for reviewer to review it and merge it if it was OK.

Git Flow Recommendation

Totally, it’s good to have a specific git flow for your development team and ask them to follow it. It will help your team to avoid facing with risky situations in pulling and pushing the codes.
Hope it being useful.
Don’t forget to share your comments with me.
Thanks.