Undo a specific file revert in TortoiseGit - tortoisegit

In TortoiseGit commit dialog (before making a commit), I selected a particular file and right click -> Revert
I have changed my mind and would like to "unrevert" this file.
I can't find anything that achieves this. There is no record in the log of this specific file revert and of course because I hadn't committed those changes there is no point to roll back to. Is this possible?

The file should be put into the Windows recycle bin before the changes were undone.
There is no other failsafe active, as the changes were not version controlled (committed).
Also see https://tortoisegit.org/docs/tortoisegit/tgit-dug-revert.html

Related

Can you do partial commit in TortoiseGit?

Native git allows partial commits: You can commit only some of the lines of your file and leave the rest for a later commit.
Is this possible in TortoiseGit?
Yes, there are official instructions in the docs.
In practice, I find this workflow useful:
Right click a file you want to partially commit
Click Restore after commit - This immediately creates an internal copy of the file.
Double click the file to edit in TortoiseGitMerge
Right click -> Mark this block for each change you want to commit now
Right click -> Leave only marked blocks to revert the other changes.
As an alternative to these two steps, you can edit the file the way you want.
Save and Close TortoiseGitMerge
Commit - this restores the internal copy of the file afterwards.
The changes you just reverted in TortoiseGitMerge are now restored in your working tree.
Update:
Starting with TortoiseGit 2.13 TortoiseGit comes with a partial staging feature in the commit dialog.
You need to enable the partial staging feature on the commit dialog, then the can open the patch view on the right side and select lines/hunks to stage/unstage.
The answer https://stackoverflow.com/a/32527098/3906760 is basically correct, however there are fewer steps required.
Choose Restore after commit in the context menu of the file you want to partially commit - This immediately creates an internal copy of the current state of the file.
Now adjust the file to only contain the changes you want to commit
This can be done using any editor you want to use, but also using TortoiseGitMerge:
Double click the file to edit in TortoiseGitMerge (or your configured diff tool)
Adjust the file to only contain the changes you want to commit.
Save and Close
Commit - this commits the selected files and restores the internal copy of the file - the original state of the file is now in your working tree again.
These steps are required as TortoiseGit does not yet support the full staging process and hunk/block selection, cf. https://tortoisegit.org/issue/2299.

How do I revert back to earlier commit using source tree

I have a project stored on my Mac and created a repository for from that location to my project. I am able to commit using source tree but now I would like to revert back to an earlier commit so all my files in folder update? I'm not sure how i do this?
Temporary Revert Back
If you want to temporarily go back to this commit, then come back to where you are.
Right click on the commit you want to revert to and click on "checkout".
Permanent Revert Back
This will add commits to revert all your work since this commit
Right click on the commit you want to revert to and click on "Reset <> to this commit".
I think in above discussion #dominones and #Giraldi maybe misunderstand each other,
#Giraldi maybe want to delete those unwanted commits permanently in the GIT, and make the git go back to a certain history commit, from there he could start all over again, like you want to be fresh from the beginning of somewhere.
while #dmonones is showing just how to revert back to a status of your code in a history, discarding some code changes you did, which will mostly end up with a new commit aiming to remove a unwanted/mistaken change,
without changing the git history.
To discard an already committed commit in git history, you need to use hard reset and push with force.

How to ignore uncommited change in Github gui for MAC?

I am using Github GUI for Mac.
Now I've some changes in my local repository, but I want to ignore them and pull latest remote repository.
I tried Repository/Pull, but got Git Error.
"•error: Your local changes to the following files would be overwritten by merge:
Classes/xxx.m
Please, commit your changes or stash them before you can merge."
I tried Repository/Synchronize, but got following error.
"Sync Failed. Please commit all your changes before syncing."
Any idea?
Place a checkmark near each of the changed files, then go to the Repository menu and click Discard Changes to Selected Files.
If you mean using MAC GUI only, check and right click the changed files then select the discard the changes.
if you want to remove your uncommitted changes, just do a checkout on those files again.
Stash is super easy too though, and it keeps your changes in a local 'bucket' or stash :)
For those on Github for Windows, it is not obvious where Discard All Changes is, so I wanted to share this:
Select Files by using check mark next to names.
Right click on Collapse All/ Expand All button with two arrows. (This button is on right side of Files to Commit box, and under Sync and Gear icons.) This is where Discard All Changes is >hidden<.
Sorry but too low level to add comment to #Leo wangs or #aspiringwebdev chain above. You gotta start somewhere...

How easy is it to roll back a file that has been checked-in in TFS?

I've (apparently) checked-in (added) a file that shouldn't have been added to a branch. I need to revert this, but since then, 20 or so changesets have been added to the repository.
I'm used to working with Subversion, where it's only a few clicks and it's out. How easy is it in TFS?
TFS is a pain to use in general (personal and biased opinion). Here's a how-to article from Microsoft on how to proceed to revert changes back (warning: more than a few clicks away).
As given in that article, the steps to revert to a prior version of (a) file(s) are:
In Source Control Explorer, right-click the file whose changeset you want to roll back, and then click Get specific version on the
context menu.
In the Get dialog box, select the prior version of the file, and then click Get. For more information, see How to: Retrieve
Old Versions of Files from
Changesets.
After this file is in your workspace, right-click the file, and then click Check Out for Edit on the context menu.
Right-click the file again, and then click Check In Pending Changes.
In the Check In - Source Files dialog box, select the file, and then click Check in.
The Resolve Conflicts dialog box appears.
Click Resolve to open the Resolve version conflict dialog box.
Select Discard server changes.
Click OK.
NOTE: To review your decision before discarding the server changes, you can click Compare to view the server and local copies
simultaneously.
In the Resolve Conflicts dialog box, click Close.
In Source Control Explorer, right-click the file, and then click Check In Pending Changes.
In the Check In - Source Files dialog box, click Check in.
As #Darin has posted, you can simply Get the state of the previous version/changeset onto your PC and then check it in as a new version, thus undoing the effect of the check in. This is dead easy and can be done from the GUI, but does involve a fair bit of faffing around.
If you're happy to use the command line, you can also command TFS to rollback the changeset for you. This does all the "work" of the above option, leaving you with a changeset in your pending changes that will undo the checkin's effect, but hopefully with a bit less effort.
If it is added by mistake, you don't want to roll back. Instead, you want to tf destroy (from the command line) that file in each of the branches.
TFS can be a bear to work with if you add a file, delete it, then re-add a new file with the same name. It makes merging much more difficult.

svn update not updating

This is rather weird. When I do a Svn update, tortoise tells me that I am at the last revision, but there are plenty of exclamation marks everywhere telling me that lots of files are out of sync.
I can delete the old files, update, then get the new version, but a mere svn update on the file, on the directory or any parent directory does not work.
The (!) red circle icon means modified, not out of synch (I don't think such concept exists in Subversion). TortoiseSVN is telling you that you have local changes that have not been committed to the repository. You can inspect them with the "SVN Check for modifications" context menu.
The /!\ yellow triangle means conflicted. TortoiseSVN already tried to merge incomings modifications into your working copy but it failed because they interfere with some of your uncommitted local changes. You can review conflicts with the "SVN Check for modifications" context menu and you can launch a GUI tool to fix them with the "Edit conflicts" menu.

Resources