DEV Community

Ngan Kim Khong
Ngan Kim Khong

Posted on

Git as a team - a simple concept for beginners.

As a developer, knowing how to use git is crucial. However, git for a beginner can be confusing. Here are a few simple concepts in git that a beginner can master before deeply diving in.

Terms:
What is a remote repository? - A repository hosting online.
What is a local repository? - A repository at your local machine.
What is a forked remote repository? - A repository you copied that is being hosted on Github.
What is the origin branch? - Your repository hosting online. The url of this repository should have your Github's username.
What is the upstream branch? - The original repository hosting online that you cloned from. The url of this repository should have the username of the repository's owner.

This may sound very simple and basic, but without understanding these basic concepts, it is easy to get lost of where you are and what you are doing

Working flow:
Working as a team, the master branch is crucial. All codes in the master branch should be working. So we would be able to keep track of which codes work or does not. Each team members should not have the ability to push their codes straight to the master branch. There needs to be at least 1 review by a lead, or another team member before the codes are merged to the master branch. Learn how to protect master branch here. And here is a guide to have any team member in your team to review before merging to the master branch.

Commands:

  1. Start working on a new feature/new change: git checkout -b <branch-name> // Create a new branch and check out the new branch. Only need to do this once. git checkout <branch-name> //Checkout the existing branch.
  2. When making a new change. Commit your change by running the following: git add . //when making a new change. git commit -m “<message>” // Commit to Github.
  3. Push change to git hub: git push
  4. And then go to Github and make a pull request waiting for approval.

This is not everything you will need, but enough to get it going :)

Top comments (0)