Fundamentals 7 min read

Comprehensive Guide to Using Sourcetree for Git Version Control

This tutorial walks through installing Sourcetree, explains core Git concepts, and provides step‑by‑step instructions for creating local repositories, committing changes, managing branches, merging, rebasing, squashing commits, handling conflicts, configuring .gitignore, and synchronizing with remote services such as GitHub or GitLab.

360 Quality & Efficiency
360 Quality & Efficiency
360 Quality & Efficiency
Comprehensive Guide to Using Sourcetree for Git Version Control

This article introduces Sourcetree, a graphical Git client, and provides the download link (https://www.sourcetreeapp.com/). It explains that Sourcetree bundles both the GUI and the underlying Git tools.

It describes the basic concepts of workspaces, repositories, and remote interactions, illustrating how the visual interface links them together.

1. Create a local repository: create a folder, open Sourcetree, select New → Create Local Repository, and specify the folder path. The folder becomes a Git‑tracked working directory containing a hidden .git folder.

2. Commit files: add a new file, stage it in Sourcetree, and click Commit to record a version.

3. View commit history: the commit graph shows nodes; double‑click a node to checkout that version, with HEAD indicating the current workspace.

4. Reset to a previous commit: right‑click a node and choose either a mixed reset (keep changes unstaged) or a hard reset (discard local changes).

5. Create a new branch: use the Branch dialog to name and create the branch; the new branch appears alongside master.

6. Work on the new branch: add and commit files as before; double‑click a branch to switch.

7. Merge to master: switch to master, click Merge, select the source branch, and choose merge options such as creating a merge commit or rebasing.

8. Squash commits (interactive rebase): right‑click a node, select Interactive Rebase, and squash multiple commits into one to simplify the history.

9. Resolve conflicts: when merging conflicting changes, Sourcetree shows the conflict status; double‑click the conflicted file, edit manually, mark as resolved, and commit.

10. Ignore files: right‑click files to add them to .gitignore; patterns can be exact filenames, wildcards (e.g., *.conf), or directory paths.

11. Push to remote: after configuring a remote repository on services like GitHub, GitLab, or Gitee, use the Push button to upload local commits.

12. Pull from remote: clone the remote repository via its HTTPS URL, then pull changes to synchronize work across machines.

The article concludes with a recommendation to practice Git commands at https://learngitbranching.js.org.

gitTutorialVersion ControlbranchingmergingrebasingSourcetree
360 Quality & Efficiency
Written by

360 Quality & Efficiency

360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.