How to do rebase --interactive in a Windows GUI - windows

I have a co-worker who's wedded to the git GUI interface for Windows; I'd like to get him rebasing interactively so he can squash commits.
I've tried using the Tools->Add to add git rebase --interactive but this just hangs when he tries it. Can the client handle interactive rebases? Is there another GUI client for Windows that can? Or perhaps there is another way to squash commits in the client?

There is no way to do it through the gui. That said, there are ways to squash commits without the interactive rebase. For instance, one could do a reset --soft 3 commits ago, add everything to the index and commit. This would effectively squash the last 3 commits.

Related

Using Github GUI for Mac and git from the terminal

Is there any problem using both the GUI version of Github and the terminal version interchangeably? For instance, If I start a coding session using the GUI, then need to do something that I only know how to do from the command line. Then switch back to the GUI.
Are there any issues with that?
Both the GUI version and the command line (terminal) version can be used interchangeably. I use both myself on a Mac and haven't encountered any issues thus far.
There is nothing wrong with this, I do it all the time. The GUI is nice because it allows you to see all the newest changes very easily and well as do quick commit + sync. But I use the terminal for finer control like forcing a branch checkout
git checkout -b newBranch
I also switch to the terminal when I want to stash changes I have made and am not ready to commit so I can go to an older branch to fix something that is needed immediately (stashing stack is awesome!)
So yea, there is nothing wrong with this approach at all. Sounds like you know what you are doing, the terminal just give you finer control.

Git Extensions usable with SVN repos?

Can Git Extensions be used without issues (or at least, with very few ones) as a SVN client? I've no problem using the command-line git-svn, but in some cases (picking lines/hunks to commit, for example) I'd rather use a GUI client.
If there are issues, I'd like to see them along with your workarounds/solutions.
As a way of an updated answer (I think this question was asked in 2011), I just started using Git Extensions for a project that uses Subversion as the repo, but I wanted to use Git locally. Learning my way into it, Git Extensions has GUI based actions for commands like SVN Fetch, SVN Rebase, and SVN Dcommit.
So, if (and I don't know because I wasn't using it in 2011) Git Extensions didn't support Subversion repos in 2011, it looks like they have that support now.
Here is an example (see red highlights at bottom):
So, to better answer your question, yes it does have support as an SVN/Git client.
git-svn creates a repository that behaves as a regular Git repository unless you are doing one of it's special operations (dcommit etc.). Thus, it is perfectly fine to interact with that repository via any external Git client as long as you use it to do things you'd normally be able to do from the command line without screwing up git-svn. (E.g. you wouldn't want to try to rebase upstream commits, GUI or not.)
(You will, of course, still have to use the command line for the special git-svn commands, unless you find a GUI that supports them.)
As alluded to by #matth, SVN support was removed from Git Extensions v3.00. However, there is a plugin (mast-eu/GitExtensions.SVN) you can install to add basic git svn commands to Git Extensions. To install it, open Plugins > Plugin Manager and browse for "gitextensions.svn".
Once installed, SVN commands are added to menu bar.
Picture of menu bar with commands

How to configure visual studio to ask to commit the code after a successful build?

Since it's the best practice to commit early, commit often I would like to be promoted with a dialog that will ask for a commit message and will commit to my local mercurial repository that I am working on.
What's the easiest way to implement such a feature?
I would like to avoid writing am add-in if possible.
One idea I had is to run a post build command that will execute a batch file.
In turn the batch file will check if the build was successful and then it will execute:
hg addremove
If nothing was either added or removed, no commit message will be requested. If any files were added or removed it will ask me for a commit message, once the commit message has been inputted it will execute:
hg commit -m "Insert message here"
Is it possible? If so, how?
First of all, I doubt you really want to do that.
Most patterns related to version control dictates that you want to know what the change was about. I build many times during the implementation of a single bug-fix, but your question leads me to think that you would think it was OK to get N commits, most of them bad, into your version control system, with no real purpose.
Now, I agree that it is best practice to commit early, and commit often, but it is not a best practice to commit blindly and commit just because it builds. You should commit when you got something you want to preserve.
Having said that, have you tried executing the hg commit command without any arguments whatsoever? The default behavior is to pop up a text file for editing, typically through your default text editor, and wait for you to save it with new content.
In other words, this should do what you want:
hg commit --addremove
However, and I strongly urge you to rethink this, you might question this decision at some point when you see a version history full of commits that are just endlessly editing files back and forth during some experimental development or bugfixing.
There's some good add-ins for Visual Studio out there as well, you might want to consider these instead:
VisualHG
HgSCC

How do you undo a hard reset in Git Gui or Gitk on Windows?

I'm using Git Gui and Gitk on Windows. How do I undo a hard reset from within the past two hours?
(Is it possible to do this from these applications, without using the command line?)
I saw this SO post, which says that undos are possible before git's garbage collection occurs. I might have quit and reopened one or both of these applications.
If you had changes in your working tree that were not committed when you did git reset --hard, those changes are gone for ever. You have to use your memory (in your head) to recreate them.
Changes that were committed after the commit to which you switched are not lost. They likely have no reference pointing to them, making them more difficult to locate. The tool to list all low-level changes to the repo is git reflog.
After you locate the commit which you want to revert to observe the hash number in the first row and use git reset --hard #hashnumber or git checkout #hashnumber to get the changes.
I found this useful line on http://quirkygba.blogspot.com/2008/11/recovering-history-with-git-reflog.html:
gitk --all $(git reflog | cut -c1-7)
This will display all the hidden changes in gitk, where you can comfortably view, point, click and create new branches.
As you mentioned the unreferenced commits are normally being kept in the repository for 30 days.
EDIT: I have to add stuff here so that my edit is at least 6 characters. I know, sometimes code fixes are less than 6 characters, but there might, after all, be something else to improve in this post.
See the answers by Brian Riehman and Pat Notz in the link in the question.
One solution is to use the command line.
In Windows, open DOS in the directory containing your .git directory.
Type something like the following to see what commit you want to go to:
"c:\Program Files\Git\bin\git.exe" reflog
To go to a certain commit, type something like the following, where the last expression is the SHA1 code of that commit:
"c:\Program Files\Git\bin\git.exe" reset --hard 5eb4080
I don't think you can undo a hard reset to get uncommitted changes back - you can undo a rebase because the blobs are still available, but if you never committed your newest changes to Git ever, anything it overwrote is most likely history. I'd love to find out that I'm wrong though!

Using TortoiseGit deleting all after a certain commit

Using TortoiseGit (I'm trying to avoid command line usage) how does one delete all commits that accended from a certain commit, and "get back in the past" (example usage: continued doing something, figured I didn't like where it was going, and decided to go "back" disregarding all in between).
In short I wish to go 5 commits "back", and delete them afterwards.
Go to TortoiseGit -> Show log. Select the most recent commit you want to keep, everything above will be erased. Then right click on it and select "Reset "master" to this" and choose Hard. Be careful though because once you do this all the commits after it will be forever lost unless they are stored off in another branch somewhere.
I've never used Tortoise anything (unless you count the electronica group), but I'll give you this info in case you don't find a way to do it with the GUI or you end up deciding to go CLI after all.
As #Tuxified mentions, you can accomplish this with git reset --hard <COMMIT>. You need to specify a commit, which can be done in any of an intimidating panoply of possible ways; the most common have forms like HEAD~4, which specifies a commit 4 commits before the head of the current branch, and deadbeef42, which specifies a commit whose SHA1 starts with 0xdeadbeef42. If you're running linux or OSX, you can get the full details on commit specifiers via man git-rev-parse, under "SPECIFYING REVISIONS".
You can also rename the current branch (git branch -m new_branch_name) and then create a new branch with its head at the place you want to revert to. The advantage is that if you end up wanting to use all or some of the stuff you did there, you can still readily access it; and if you typo the commit, you're saved from a big holycrap moment. Plus git branches are super lightweight so the only real downside is that there will be another branch listed. To make the new master branch you would use git branch master <COMMIT>, and then you check it out. So the net effect here is the same as the first option, except that you still have your old changes saved in the branch new_branch_name. You can even merge those changes back in later, after new commits to master, if you feel like it.
Note that either of these techniques are considered "rewriting history" and will cause issues if you're sharing your repo with others. If you're being smart and pushing to a backup repo in cloud city or another pc, you will have to fix things on that end before you can push to it again.
This is probably way more info than you need right now, but if you end up using git a lot you'll probably want to learn this stuff at some point. Sorry I don't know how to use Tortoise...

Resources