Many of you might have been using GIT for your personal projects or large team based projects. We at Rokomari heavily depend on GIT. For better outcome on collaborating projects, we follow a specific method with git. I am going to share this here.

First of all we need to arrange repository in a specific way before starting to code.

Let,

You will work with a company named ‘Company’ and they keep all the repository to Github. You are assigned to a new project ‘Syndicate’. The repository is created by the admin user of ‘Company’.

Repository URL: https://github.com/company/syndicate
Your personal GITHUB user is ‘AZLAN’ and you have read access to the repository.

To start working with the project you need to do the following:

  1. Clone the project to your workstation: git clone https://github.com/company/syndicate.git
  2. Fork the project to your account. It will ask to choose the user or account where the fork will be created, choose your personal account.
    A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.
  3. As soon as your fork created, It will be created in your account if you have selected your own user. Normally the forked repository URL will be as follows: https://github.com/azlan/syndicate.git, copy that git url wither ssh or https.
  4. In your workstation, go to the project directory which is already cloned.
  5. Check how many repository remote destination is added: git remote -v
    Normally you will see two lines with same git repo, one for fetch and other for push.
  6. Now you need to add remote of forked project: git remote add azlan https://github.com/azlan/syndicate.git
  7. Now again check the remotes: git remote -v
    It should show two remote in 4 lines with paired of push and fetch. Among them, two should be with azlan

Now you can start working. The steps below is repetitive every time you need to work with new issue with new branch.

  1. Make sure you are in master branch: git checkout master
  2. Perform a pull request from origin master: git pull origin master
  3. Perform a push to your fork to keep your master updated with latest code: git push azlan master
  4. Create a feature branch: git checkout -b '<NAME_YOUR_BRANCH>'
  5. Do your changes. perform:
    git add .
    git commit -am "<COMMIT_MESSAGE>"
  6. Push the branch to your fork: git push azlan syndicate
  7. Work as much as you want, commit and push with step 5 and 6.
  8. Finally make a PR from github.com. If you go to the repository, You will see a message to create pull request.
Previous ArticleNext Article
Fahad Ahammed is a System Administrator and DevOps in Software Department of OWSL. As a Linux enthusiast he breathes in server consoles or terminals. You can have a look to his website here: https://fahadahammed.com

Leave a Reply

Your email address will not be published. Required fields are marked *