Cloning downloads a remote repository to your local machine.
- Right-click in the folder where you want to store the repository.
- Select
Git Clone...
. - Enter the URL of the remote repository.
- Choose the directory for the local repository.
- Click
OK
.
A comprehensive cheat sheet for using TortoiseGit, a Windows shell extension for Git, covering essential operations, commands, and best practices for version control.
Cloning downloads a remote repository to your local machine.
|
Example: Cloning from GitHub: Repository URL: |
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 uploads your local commits to the remote repository.
|
Important: Make sure you have committed your changes before pushing. |
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 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 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. |
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 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 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. |
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. |
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. |
|