Clone and Create Git Branches with TortoiseGit
In this article
This guide shows you how to clone a remote Git repository and create branches using TortoiseGit, the Windows shell integration for Git. You'll learn the essential steps to copy a remote repo to your computer, then create and work on a new branch without affecting the main codebase. Before starting, ensure you have Git for Windows and TortoiseGit installed, and that you have the URL of the remote repository (e.g., from GitHub, GitLab, or a company server).
What You'll Need
- TortoiseGit installed (download from the official site, includes Git for Windows if you choose the full installer).
- A remote repository URL (HTTPS or SSH). If SSH, you'll need your SSH key configured in TortoiseGit settings.
- If the remote is private, you'll need valid credentials (username/password or access token).
Step-by-Step
- Create a local folder for the clone. In Windows Explorer, navigate to where you want the repository to live (e.g.,
C:\Projects). Create a new folder if needed, or use an empty one. - Open TortoiseGit clone dialog. Right-click the empty folder (or inside it) and select Git Clone… from the context menu.
- Enter the repository URL. In the URL field, paste the remote repository URL. The Directory field should auto-fill with the folder path you right-clicked. Leave other options at their defaults for a standard clone.
- Start the clone. Click OK. A window will show the cloning progress. When it finishes, you'll see a success message. Click Close. Your local copy is now ready.
- Open the repository. Right-click inside the cloned folder and select TortoiseGit → Show Log to verify you see the commit history. This confirms the clone worked.
- Create a new branch. Right-click the folder again, go to TortoiseGit → Create Branch….
- Name your branch. In the Branch field, type a descriptive name (e.g.,
feature/login). Make sure the Based on field points to the branch you want to branch from (usuallyorigin/masterororigin/main). Leave the Switch to new branch checkbox checked so you start working on it immediately. - Create the branch. Click OK. TortoiseGit creates the branch locally and switches your working copy to it.
- Verify the switch. Right-click the folder and select TortoiseGit → Show Log. The log window will show your new branch name in the header. You can also run
git branchin a command prompt inside the folder to see all local branches. - Make changes and commit. Edit files as needed. When ready, right-click the folder, select Git Commit…, write a commit message, and click Commit.
- Push the branch to remote. To share your branch, right-click the folder, select TortoiseGit → Push…. In the dialog, ensure the Local branch is your new branch, and the Remote field is set to
origin. Click OK to push. After this, your branch exists on the remote server.
Common Mistakes
- Cloning into a non-empty folder – TortoiseGit may refuse or cause conflicts. Always use an empty folder.
- Forgetting to switch to the new branch after creating it – if you uncheck the switch option, you'll stay on the old branch and your changes go there.
- Pushing to the wrong remote branch – double-check the Remote and Local fields in the Push dialog.
- Using an incorrect repository URL – a typo in the URL will cause an authentication or not-found error.
Tips
- Use descriptive branch names that indicate purpose, like
bugfix/issue-123orfeature/checkout. - Before creating a branch, fetch the latest changes from the remote (right-click → Git Fetch) to avoid basing your work on outdated code.
- If you're new to Git, use the TortoiseGit documentation (right-click → Help) for context on any dialog.
- To see all branches (local and remote), use TortoiseGit → Show Log and click the Branches dropdown.
Troubleshooting
- Clone fails with authentication error. Check your credentials. For HTTPS, you may need a personal access token instead of a password. For SSH, ensure your SSH key is added to the TortoiseGit settings (right-click → TortoiseGit → Settings → Git → Remote).
- “Repository not found” error. Verify the URL is correct and that you have access to the repository. If it's private, confirm your account has permission.
- Branch creation succeeds but no files change. This is normal if the new branch points to the same commit as the original branch. Make a change and commit to see the branch diverge.
- Push rejected. Often this means the remote branch has commits you don't have locally. Run Git Pull (or Fetch then Merge) to integrate remote changes, then push again.
- Can't see the new branch in the remote. After pushing, check the remote repository's web interface. If it's not there, you may have pushed to a different remote or branch name.
Frequently Asked Questions
Do I need to create a branch on the remote first?
No. You create the branch locally and then push it. The remote branch is created when you push the local branch for the first time.
Can I clone a specific branch instead of the default?
Yes. In the Clone dialog, under Branch, you can type a specific branch name (e.g., develop) to clone only that branch. By default, TortoiseGit clones all branches.
How do I delete a branch?
To delete a local branch, right-click the folder, select TortoiseGit → Switch/Checkout, choose another branch, then use TortoiseGit → Delete Branch…. To delete a remote branch, use TortoiseGit → Show Log, right-click the branch in the Branches dropdown, and select Delete Remote Branch.
What's the difference between 'origin/master' and 'master'?
'origin/master' is a remote-tracking branch that mirrors the state of the 'master' branch on the remote. 'master' (without prefix) is your local branch. When you create a new branch, you typically base it on 'origin/master' to get the latest remote state.
Can I create a branch from a specific commit?
Yes. In the Create Branch dialog, click the … button next to the Based on field. This opens a commit selection window where you can pick any commit from the history.
Why does my push ask for a password every time?
If you're using HTTPS, TortoiseGit may not cache your credentials. You can enable the Git credential manager (TortoiseGit → Settings → Git → Credential) to save your password securely. If using SSH, ensure your key is added to the SSH agent.