Switch / Checkout from Git Synchronization dialog - tortoisegit

I need to do a lot of switching between branches from a remote repository to inspect code, perform code reviews, contribute to other developers' work and such. I'm not a command line fan so I use TortoiseGit almost exclusively. I also prefer TG over Git clients in various IDEs because I find it really shines when you run into more complex operations like non-trivial three-way merges.
I noticed I find myself clicking A LOT, though. To switch to another branch consists of: Revert or stash any current local changes, fetch (to get the latest remote branches), switch/checkout. So I started looking into the "Git Synchronization" dialog, hoping that I could perform all those operations from within one dialog with a few less clicks, dialogs and OKs.
However, I simply cannot find the switch (or checkout) functionality in that dialog. Is that simply missing, or is there some other Git operation or combination of operations that accomplishes the same?

Quick solution
You can simply select a different branch from Local Branch dropdown in Git Sync dialog. When you subsequently invoke Pull, TortoiseGit will force the checkout automatically:
For other operations (Fetch, Push) switching to a branch is not necessary. However be cautious with the Commit and Show log buttons as they will always apply to the current branch (not the branch selected in Local Branch dropdown) and no checkout will be forced.
Solution using Switch/Checkout dialog
If you need to use full Switch/Checkout dialog TortoiseGit dialog, you can use Browse references dialog which you can invoke from Git Sync dialog by clicking on the ellipsis button next to the Local Branch dropdown.
In the Browse references dialog there is a list of available branches. You should right click the desired branch you want to checkout and select Switch/Checkout to this from context menu. Switch/Checkout dialog will pop up. After completing the checkout, return to the Browse references dialog where the desired branch is selected and click OK. Now the desired branch is checked out and also selected as a Local Branch in Git Sync dialog.

Related

Rearrange Git branches in Xcode?

I use Xcode's built-in Git/Hub integration for day-to-day use. In one project I made a branch, and when you use Commit... Push to remote", you are asked to select which branch to push to.
The problem is that the branch, which is used only rarely, is the first entry in the push pop-up. I often check into the wrong branch during a push simply because I don't notice it is the default selection.
Is there any way to sort these entries, or temporarily mark one so it does not appear or is greyed out? You cannot drag them in the source control pane on the left and there do not appear to be any options anywhere.

TFS undo to last shelve

What I want to do: I made some changes in code and I want to make some kind of "checkpoint" (like git commit), then continue working and being able to simply undo changes to last "checkpoint". I don't want to use Check In.
If I'm not mistaken, it could be done by Shelving, but I'm unfortunately not sure how exactly I can achieve that.
Thank you.
In the "Pending Changes" tool window in Visual Studio just select "Shelve" at the top, enter a name and click the "Shelve" button:
To go back to your "Checkpoint", restore your Shelveset via Actions => Find Shelveset => Rightclick => Unshelve
Shelving is similar to stash in git. To replicate that kind of workflow would involve either checking out to a previous changeset and/or rolling back changesets. I've created multiple shelvesets before (V1, V2, etc), but it is less than ideal.

How to change default action for "pushing" after committing?

After committing some code locally in TortoiseGit, the window that shows that the operation was successful offers to push the commit (or, in fact, any local commits) to a remote repository. This can be achieved by clicking a button with a dropdown arrow, from where Push, or some other actions can be chosen.
Normally, Push is shown by default, the other actions have to be selected from said dropdown menu.
I am now looking at a repository that was originally imported from SVN (using TortoiseGit). After importing all commits, I have manually reconfigured the remote master to point to a different, true Git repository.
However, after committing, the default action of the aforementioned button is always SVN DCommit for this repository, even after choosing Push several times.
How can I change the default action to Push?
The default of the post action button cannot be changed right now (as of version 2.3.4; see https://tortoisegit.org/issue/2227).
The "DCommit" entry is only shown for Git repositories which have an SVN remote. When you remove the SVN connection the default will be "Push".
Also, with a recent version of TortoiseGit the "OK" button of the commit dialog is a drop down menu where you can select "Commit & push" which should save you a click...

How can I cancel a Merge in TortoiseGit?

I must be missing something.
I am a git Newbie. I unintentionally created a Branch when I did a Switch/Checkout on a single file (reverting to a previous version).
I then tried to Merge that right branch. But files were in Conflict, so I cancelled.
Now, everytime I try Commit or Switch I get an error that "did not exit cleanly" but when I try to Commit I get the Conflicted Merge.
How can I cancel the request for the Merge?
You have two choices:
Go to the log dialog and perform a hard reset (on the latest revision of your branch)
Open the context menu in explorer and select "Abort merge" which basically does the same.
Both options will reset all files in the working tree and the index "back" to the latest version of your current branch.
Update: Starting with TortoiseGit 2.4.5 you can also select "git reset --merge" in the "Abort merge" dialog. This option resets the index and tries to restore the pre-merge state of the repository.

What is the purpose and function of Xcode's source control "Show Remote Status" menu option?

When working in Xcode on a project that's under git source control, I noticed the following menu item:
File > Source Control > Show Remote Status
and, when toggling it, it changes to:
File > Source Control > Hide Remote Status
I do have a Bitbucket git remote configured for the sample project I'm working on, but I can't figure out what that menu is supposed to be showing me, or where!? When I toggle it, there is no visible change to my Xcode user interface. I do have some changes that were committed to the local git repository only, not yet pushed to the remote, and I was expecting, somewhere, to see that the remote isn't current, when "Show Remote Status" is toggled on.
So, what is this "Remote Status" information that Xcode is supposed to be able to show, and where am I supposed to be looking for it? Is this feature equivalent to something that is typically queried on the git command line – and if so, what? Is there a window or panel I'm supposed to have open in order to see this information? I do have my navigator area, debug area, and utility areas all visible.
I searched Xcode documentation, Stack Overflow, and Google each for "Show Remote Status" and "Hide Remote Status", but none of the results were particularly enlightening.
I haven't used Xcode before (yet), but since Git is a distributed version control system, your local repo can become out of sync with the remote repo, i.e. their states can diverge. That is probably why you're given the option to see what the status of the remote is, for example, if any of its branches have been updated (i.e. have new commits), if there are any new branches on it, and if any branches have been deleted from it.
From the command line, you would normally get this kind of information by running git fetch --prune <remote> to update your local remote-tracking branches, which track the status of the branches of your remote (of course!). You can then examine the remote-tracking branches to see what the status of the remote repo is.
There is also the git ls-remote <remote> command, which will do a network operation to talk to the remote and return a list of the remote's current references/branches, but that is more of a plumbing command that is not really meant for typical Git users, it's more meant for Git developers to create Git tools.

Resources