Get started with Git version controlling
Version controlling using Git
For this tutorial, I am using TortoiseGit as the Git client.
You can download TortoiseGit from here.
1) Get a clone of the project repository
- Get clone URL from Git.
2. Navigate to the location where you need to have the cloned project.
3. Right click and click on Clone.
4. Paste the clone URL and press Ok button.
5. Once the cloning process completed, press Close button.
Note: You can get a clone of the project repository using command line as well.
git clone <remote_url>
2) Create a local branch from the master branch.
- Go inside the project folder.
- Right click and navigate to TortoiseGit → Create Branch
3. Provide a name for the branch and click Ok button.
Note: You can create a local branch from the master branch using command line as well.
git branch <branch_name>
3) Switch to that new local branch
- Right click and navigate to TortoiseGit → Switch/Checkout
2. Select the new branch and click on Ok button.
Note: You can switch to that new local branch using command line as well.
git checkout <branch_name>
4) Then work on that branch
You can do your changes now.
5) Commit your changes
- Right click and navigate to Git Commit → “Branch name”
2. Enter a commit message and click on Commit button.
Note: You can commit your changes using command line as well.
First add new files to the Git repository.
git add <file or directory name>
Commit your changes into the local repository.
git commit -m "Commit message in quotes"
6) After committing your changes, get a pull from the master branch and resolve the conflicts if needed
- Right click and navigate to TortoiseGit → Pull
2. Select the master branch and click on Ok button.
3. Click on Close button.
Note: You can get a pull from the master branch using command line as well.
git pull <remote_url/remote_name> master
7) Push your changes to the remote
- Right click and navigate to TortoiseGit → Push
2. Click on Ok button.
3. Click on Close button.
Note: You can push your changes to the remote using command line.
git push <remote_url/remote_name> <branch_name>
8) Create the pull request
- Go to Git and click on “Pull requests”.
2. Click on “New pull request” button.
3. Change the source branch to the created branch and click on “Create pull request” button.
4. Click on “Create pull request” button.
9) Merge the pull request
- After reviewing the pull request, any team member can merge the pull request to the master branch by clicking on the “Merge pull request” button.
2. Then click on “Confirm merge” button.
3. Now the pull request is successfully merged with the master branch. You can delete the branch you have created by clicking on “Delete branch” button.