Unable to create patch using TortoiseGit with working copy changes [duplicate] - tortoisegit

This question already has answers here:
Create a git patch from the uncommitted changes in the current working directory
(8 answers)
Closed 5 years ago.
I am trying to create a patch using TortoiseGit, but I am not able to get the patch with working copy changes, means may there is no option for working copy changes in TortoiseGit.
But I am able to create patch using committed changes. But I need the patch only for uncommitted changes. Please help on this.

Open Log Message dialog, Right click on Working tree changes, and Click Show changes as unified diff
A TortoiseGitUDiff dialog is opened, Click the File menu, and Click the Save as...
Give the patch a file name, Save, and that's it.

You can open the context menu on the Working Tree folder and select "Diff" or "Check for modifications" (you might have to hold Shift while opening the context menu).
On the following dialog there is a "Save unified-diff"-button which provides the requested functionality.

Related

Searching for a Blame

I'm trying to find some changes I made to some code within a project. This is a team project having multiple contributors.
Is it possible to search for a particular blame within Xcode?
It would be easier for me to search via blame than to remember a particular file and line number.
Inside Xcode, open the left side menu and navigate to Source Control Navigator. You can also do this using the keyboard shortcut cmd2
In there, select the branch you're working on.
In the text box in the top right corner, start typing your version control username and press:
Author:{your-username}
This will show you all commits you have pushed to the repository. You can select a commit to see which files were changed and access the respective files directly from there.

I accidentally closed my Xcode application. How do I undo any changes?

I was testing out some new swift code. I knew that if I made any mistake I could simply revert back to my old code by pressing Command+Z.
But I accidentally closed my Xcode Editor while writing new code.
How would I undo the new changes and go back to my old original code? I did not make use of github for this.
There might be a chance you can view the file's old history. Check out George Marmaridis' answer
Here is what he says:
You might not be out of luck. Although Git can't help you, Finder may be able to come to the rescue!
If you have not turned off the Versions feature (which by default is turned on and you need a Terminal command to disable), then do the following:
Quit Xcode.
Open the file you wish to bring back your lost changes to using TextEdit.
Go to File > Revert To > Browse All Versions...
Scroll through the available versions. Hopefully you will have many available to choose from.
Select a version and hit Restore.
Follow 2-5 for all necessary files.
Launch Xcode. You should now see the M next to these files in Project Navigator indicating they include uncommited changes (the changes you previously discarded).

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.

SVN Auto Update

I'm using AnkhSVN with Visual Studio 2010.
When I start to edit a file, I'd like to either automatically update the file from the repository, or be warned that it needs updating.
Is this possible?
Would keeping the working copy updated be of use?
If so, you can use this:
How do I automatically update a Subversion working copy?
There's not really a way to do this in Subversion, except when you're using locking and svn:needs-lock on files. The reason is that when you start editing your file can be up to date, but when you want to commit it's changed, and needs updating. Subversion will check for this case and notify you to update when you try to commit.
To get notification of files others are working on, you can go to the "Recent changes" tab in the Pending Changes window (View -> Pending Changes, then click the 3rd tab from the top). You can configure this to update every 'X' time, UI should be pretty self explanatory here.
See my answer here for info on svn:needs-lock, but make sure you understand the pitfalls of exclusive locking of files.

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.

Resources