How to force TortoiseGit to NOT show push all branches windows all time? - tortoisegit

Previously when I clicking button "Commit and push" in tortoise git, it showed "push all branches" window only when I had a new branch. After update, this window will be shown every time after clicking "Common & Push".
How to skip this window?

When pushing new branch, tortoise git shows 2 checkes at the end of window, with labels:
Always push to the selected remote archive for this local branch
Always push to the selected remote branch for this local branch
Tick them or in branch browser window (can be reached from switch/checkout branch command or other places) select command select tracked branch

Related

How to clear the branch names from TortoiseGit

In my git repo origin, i used to have the branches called "test" and "master". I removed the branch "test" from origin. And pushed a new branch "TEST". Notice that I basically removed the "test" with all small case and added a branch with all caps "TEST".
I ran "git fetch --prune" on my local machine. And then removed the branch test ("git branch -D test"). So, in my local i now have TEST and master branches. And i only see these 2 branches when i run "git branch" using git bash.
But, the issue i am seeing here is that, tortoise git is still showing the "test" branch that i already removed from my origin and local. Please help me in getting rid of the "test" branch from tortoise git as well. This is important for me, as there are other team members that use only tortoise git and not git bash and they see the same issue. So, i should atleast solve this issue for them.
Go to the directory of a git repo. Right click in the directory and you will see this menu.
Click on Git pull. You will see the following dialogue.
As you can see above, the Remote branch dropdown still displays "test"
if we click on git push from the first screenshot, this dialogue will appear.
And the remote dropdown in this case displays only "test" and not "TEST". Because of this, when people push this way, it is resulting in creation of a new branch called "test" in the origin, which is not intended.
I know we can manually type "TEST" for the remote branch before pushing. But, it would be nice if the "test" goes away which will prevent people from accidentally pushing to the wrong branch "test".
Selective removal: Mousehover an entry and then press shift+del.
Removing all settings: Go to TortoiseGit settings -> Saved Data and hit the appropriate clear button (cf. https://tortoisegit.org/docs/tortoisegit/tgit-dug-settings.html#tgit-dug-settings-saved-data)

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.

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.

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.

Resources