Fundamentals 11 min read

Master Sourcetree: A Complete Visual Guide to Git Management

This comprehensive guide walks developers through installing Sourcetree, adding repositories, visualizing branches, performing fetch, pull, commit, stash, merge, tag, and other Git operations with step‑by‑step screenshots and command examples, helping them master cross‑platform Git workflow without IDE constraints.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Sourcetree: A Complete Visual Guide to Git Management

Introduction

Sourcetree is a free, cross‑platform Git client for Windows and macOS that visualizes repositories and simplifies common Git actions through a graphical interface, making it useful for Java, Python, Android, or any development environment.

Adding Repositories

Clone a remote repository by entering its URL. On macOS, use the git remote add origin http://10.10.100.6:3000/sl/shaolei.git command shown in the UI; on Windows, follow the analogous menu steps.

Fetching and Pulling

Use the Fetch (macOS) or Get (Windows) command to retrieve remote changes. After fetching, pull the latest commits to keep the local branch up‑to‑date and avoid conflicts.

Committing Changes

Select unstaged files and click Stage Selected (or Stage All ) in the file pane, write a descriptive commit message in the bottom pane, optionally check Push immediately , and click Commit . If not pushing immediately, use the menu Push button later.

Staging and Discarding

Staging moves changes to the local index for the next commit. Discarding removes unwanted additions (+) or deletions (‑) from the index; you can discard individual lines or whole change blocks.

Conflict Resolution

When a conflict occurs, stash local changes with git stash, pull the remote version, then apply the stash. Resolve conflicts by choosing Use My Version or Use Their Version for each file, then commit the resolved state.

Branch Operations

Creating and Switching Branches

Right‑click a commit node and select Create Branch to start a new development line (e.g., feature, integration, production). Switch branches by double‑clicking the desired branch in the sidebar.

Pushing Branches

New local branches are not visible remotely until you push them with git push origin <em>branch‑name</em>.

Merging Branches

Merge a source branch into the current branch via the UI; resolve any conflicts as described above, then push the merged result.

Ignoring Files

Configure ignore rules to exclude directories like bin/ or target/ from version control. Ignored files must be untracked; otherwise, delete them from the repository first.

Tagging

Create lightweight tags (e.g., git tag v1) to mark releases, and delete tags with git tag -d v1. Tags appear in the UI for quick reference.

Stashing (Temporary Storage)

Use git stash to save all current changes without committing, allowing you to switch branches or pull updates safely.

Blame and Log

Right‑click a line and select Blame to see the author of each change. View the full commit history with git log in the UI, which displays commit messages, authors, and timestamps.

Viewing File History and Versions

Open a file’s change history via the context menu, then select Open Historical Version to inspect previous snapshots generated as temporary files.

Good Practices

Discard meaningless changes to keep commit history clean.

Assign tasks by module to reduce overlapping work.

Resolve merge conflicts immediately after merging.

Keep change blocks small within a single file.

When resolving conflicts with your version, inform teammates of the decision.

Conclusion

By following this guide, developers can handle the majority of everyday Git tasks—cloning, committing, branching, merging, tagging, stashing, and reviewing history—using Sourcetree’s visual interface, independent of any specific IDE.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

mergeBranch ManagementSourcetreestash
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

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.