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

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...

Related

Switch / Checkout from Git Synchronization dialog

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.

Open old Github Commit in Visual Studio

Steps:
Navigate with a browser to the github.com/user_name/repo_name/commits page
To the right of the desired repo click the far right <> button
with the tooltip "Browse the repository at this point in the
history."
Note the page just navigated has a URL like
github.com/user_name/repo_name/tree/Some_UID
Click on the green "Code" button in the repo, then click "Open
in Visual Studio".
After launching the MS VS Web Protocol Handler Selector from the
popup dialog (with the "always allow Github to ..." checkbox), VS launches showing the Team Explorer dialog, with the URL of just
the base repo (github.com/user_name/repo_name) in the remote URL
box.
Attempt to replace the default URL with the desired commit
(github.com/user_name/repo_name/tree/Some_UID) in the box and then
click the Clone button.
The following message is generated at the top of the dialog:
Git failed with a fatal error.
repository 'https//github.com/user_name/repo_name/tree/Some_UID/' not found
An empty directory with the name Some_UID is also created in the base repository directory.
Is there another way, preferably from the VS/Github GUI, of opening an older commit in Visual Studio?
Edit: The obvious solution is to open the Git history window in VS and right click on an old commit in order to revert to it. Given that Git Revert creates a new commit, which adds to the Git history chain,- the idea here was, in fact, to somehow open a new solution (in a different directory) with the old commit for quick testing, and delete it when finished. An idea which might seem feasible so long as the new (temporary) solution had no Git, or at least no bindings to Git that would point to the original solution.
Clone the origin project.
Find the commit id, then reset to the id locally.
git reset --hard xxxxCommitIDxxxx

How to checkout a tag using TortoiseGit in an empty directory on you local PC?

My machine is Windows 7 operating system. The Git version is 2.23.windows.1. I have TortoiseGit 2.8.0.0 version.
There is a remote repository on BitBucket. It has many tags one of them is v1.5.
On my local PC there is an empty directory. In it I want to checkout the v1.5 tag using TortoiseGit. How can I do that?
I know how to do it in case of SVN as each tag has a different URL so TortoiseSVN is pretty easy in such a case but how to do it in Git using TortoiseGit?
From the TortoiseGit Manual, you can open the "Switch/Checkout" dialog by right-clicking on the repository's folder and clicking "Switch/Checkout...", then selecting the "Tag" radio button and selecting your tag (in this case, v1.5).
If you just need the source code of a specific version and no further version conrol locally, you can easily download the source code of a tag directly on BitBucket/GitHub/GitLab. For this go to releases and there you will find the download links.
Using TortoiseGit you first have to clone the repository (open the context menu, select "Git Clone" and enter the URL of the repo, cf. https://tortoisegit.org/docs/tortoisegit/tgit-dug-clone.html). After that, you have to check out the specific version. For this open the "Switch/Checkout" dialog (from the contextmenu, cf. https://tortoisegit.org/docs/tortoisegit/tgit-dug-checkout.html) and select the tag you need.
Technical detail: In Git you cannot check out a tag. You can check out a specific commit, but then it is hard to do further work (this state is called "detached HEAD"). It is better to create a branch for a tag and check out this (this is what TortoiseGit does by default unless you uncheck the "Create new branch" checkbox).

How do you auto-push commits to remote repository in TortoiseGit?

I have set up a remote repository with the URL, the credentials (accounts) set up for that repository, and I have my local branch ready to push new commits to the repository.
Now, I would like to auto-push my commits to the remote repository in TortoiseGIT, after committing my changes.
Below shows how to set up the configurations in TortoiseGIT for auto-pushing commits.
Using the default installation and configurations for TortoiseGIT v2.3.0.0 and Git for Windows 2.11.0.windows.1:
Prepare your commit.
Do Right click > Commit... and it should open up the Commit dialog.
Once your commit messages are typed in, at the bottom, select the dropdown menu on the Commit button, and choose Commit & Push.
It should then open up the Push dialog.
In the Push dialog, in the Ref section, choose the remote branch via the dropdown menu, or type in the remote branch name. It must not be empty.
Change the Destination section if necessary.
In the Options section, enable the bottom-most option: Always push to the selected remote branch for this local branch.
Press OK.
Your commit will then be pushed to the repository. Subsequent commits will automatically be pushed to the repository once you commit your changes.

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