Git is for working people

Tram Ho

Git is for working people

Hello everyone, in this article I will introduce and share experience using Git when I go to work. It may be lacking, but I hope it will be useful for newcomers to my work environment. If there is something wrong, please tell me, so I can improve the article better.

I will not introduce Git with the command line anymore, but in this article I will introduce you to TortoiseGit UI.

Managing Source Code On Simple Github With TortoiseGit.

Everyone has their own options, they can use Git through gitbash, but when I went to work, I was introduced and used by TortoiseGit, I felt easier and the operation speed was much faster.

Before I get started, I will introduce you a little bit about Git. I understand it roughly like this, when working together, we will definitely have common or private files to share with other people in the team or each person will have their own task, working on their own assigned part. but when done then probably not have to send all to a person to synthesize or merge code. For added convenience, we will use Git to manage the source. In the picture you can see, the computers of the employees (local) will be connected to the repo (remote), the main task will be pulling (pulling from the remote to the local) and push (pushing from the local up). remote for other people to use). Teamwork will be greatly improved, source management is much easier.

Part 1: How to Setup TortoiseGit

  1. First, you must have an account at github.com , click the link and create an account for yourself, if you already have an account, you can skip step 1.
  2. Create a repository and then continue.
  3. Next we download git-for-windows here . And install into the machine.
  4. Download and install TortoiseGit here . Download additional language packs if you want (optional)

If not, you can follow the video following the link

Part 2: Instructions for using and sharing experience using TortoiseGit

1. A quick look at how to use TortoiseGit

  • I created a repository on github.com named “git-test-repo”
  • Clone now
  • Enter url + select branch + name directory of clone
  • Clone successful, very easy to use, right
  • Let’s try some basic operations, change the style from cmd -> use UI only hehe (add file -> push file up -> edit try on github (like file edited and push from other machine) – > pull on)
  • After the next commit, there are usually 2 options to commit + push up if you make a brach alone or inactive (open file or edit file) to the file who’s doing. However, according to my advice, you can pull on r push up.
  • However, this is the repo I just created push always.
  • F5 github and see if the repo has been updated
  • Edit the file on the repo
  • Ok, let’s go back now
  • Done
  • Check file test.text to see if it has changed?

2. Here I will share some tips when using Git

– First, before starting to work, pull the latest source, or say exactly before creating or editing a certain file, we must make sure that the file is the latest version on Git

Why did I give this tip? Because when I first went to work, I often forgot to pull the latest source, but I updated that file and then when I commit and push the file up, there’s a conflict that you guys know already, conflict fixes sometimes it is very laborious. and even have a headache, so to limit this problem, please pull back and then do not do anything, not crying without tears hehe

– Next, the procedure to create a branch to code and merge into fast develop extremely fast 

Step 1: create a folder under a quick sub-name, for example depchai_branch, then clone the develop branch (very important) here I have created the develop branch already, create the folder and then clone back

  • develop branch on remote
  • develop branch on local (that is our machine)

Step 2: Create a branch and then switch to that branch

  • I created the “depchai” branch.
  • switch to the “depchai” branch

Step 3: push on the remote, too easy is not it 

  • Done, let’s check the remote

Step 4: After the code is finished, need to merge into quick develop, we do the following:

  • There are many ways to create merge requests, but I will make the easiest + safest hehe
  • First things have to change compared to fast depchai compared to fast develop
  • Then, you go on top of github or gitlab to create merge request (github is a pull request)
  • Choose fast need compare, here is branch depchai and quick develop
  • We will scroll down to replace the difference between the two quickly
  • Create a pull request
  • Usually in this step, if it is ok then merge alone or not, then give the link merge request for PM or teamlead review
  • Here I am PM so I always merge
  • Now check if the branch of the develop has merged -> it’s too easy to create branches and merge branches, isn’t it hehe

– Next, when you update the code, only to touch the lines that you change from the source, should not change the old lines.

  • In this tip, I also guide you to compare files before and after editing or comparing with older commits
  • Here, I will edit the file develop.txt
  • Try comparing it with the old source and the current file
  • Select items to compare
  • The highlighted areas are the parts that have changed
  • When you want to change the line of the file you are doing the same as the previous commit, just click on the line and then click “use left block” then control + s is ok
  • This compare method is very convenient for you to compare if you have updated the correct format? is there a shortage? or even conflict resolution

There are a few other tips, but wait for me to update and study carefully then update for you guys.

Share the news now

Source : Viblo