Catalog / TortoiseGit Cheat Sheet
TortoiseGit Cheat Sheet
A comprehensive cheat sheet for using TortoiseGit, a Windows shell extension for Git, covering essential operations, commands, and best practices for version control.
Basic Operations
Cloning a Repository
Cloning downloads a remote repository to your local machine.
|
Example: Cloning from GitHub: Repository URL: |
Committing Changes
Committing saves changes to your local repository.
|
Best practice: Write clear, concise commit messages explaining why the changes were made, not just what was changed. |
Pushing Changes
Pushing uploads your local commits to the remote repository.
|
Important: Make sure you have committed your changes before pushing. |
Branching and Merging
Creating a Branch
Branching allows you to work on new features or bug fixes in isolation.
|
Tip: Choose descriptive branch names related to the feature or issue you’re addressing (e.g., |
Switching Branches
Switching Branches moves your working directory to a different branch.
|
Note: Ensure you have committed or stashed any uncommitted changes before switching branches to avoid conflicts. |
Merging Branches
Merging integrates changes from one branch into another.
|
Conflict Resolution: If conflicts arise during the merge, TortoiseGit will prompt you to resolve them. Use a merge tool (e.g., TortoiseMerge) to compare and edit the conflicting files. |
Advanced Features
Stashing Changes
Stashing temporarily shelves changes you’ve made so you can work on something else, and then come back and re-apply them later.
|
To re-apply stashed changes: Right-click on the folder, select |
Reverting Changes
Reverting undoes changes to a specific file or commit.
|
Caution: Reverting a commit creates a new commit that undoes the changes. It doesn’t erase the original commit history. |
Resolving Conflicts
Resolving Conflicts occurs when Git cannot automatically merge changes from different branches.
|
Tip: Communicate with your team to understand the changes and agree on the best way to resolve conflicts. |
Troubleshooting
Common Issues
Problem: Cannot push changes due to remote changes. Solution: Pull the remote changes first using |
Problem: Working directory is dirty (uncommitted changes). Solution: Commit or stash your changes before switching branches or performing other operations. |
Error Messages
Message: “fatal: refusing to merge unrelated histories” Cause: Attempting to merge branches with completely different histories. Solution: Use the |
Message: “Your branch is behind ‘origin/master’” Cause: Your local branch is out of sync with the remote. Solution: Pull the latest changes from the remote. |
Useful Commands (Git Bash)
|