How can I get my stashed files back to where it was before stash? - tortoisegit

I got a pop-up in my git "The current working tree is not clean. do you want to stash the changes?" It had two options stash and abort i selected "stash" now I don't see my previous changes in my commit list how can I get my changes back? Please answer emergency!!!!!!

Open the context menu in explorer on the repository. Then go to the TortoiseGit submenu and select "Stash Pop".
cf. https://tortoisegit.org/docs/tortoisegit/tgit-dug-stash.html

use below command to get back the stashed files :
git stash pop

Related

In Team Explorer in Visual Studio, can you show stash history?

When using the Team Explorer section of Visual Studio, is there a way to see a stash history? For instance, say someone had stashed changes and then when done had popped the changes. Is there a way to show those stashing and popping changes in the View History option? Or possibly if someone new to stashing didn't pop the stash and only did an apply to the stash, then a month or so later they saw the stash showing in the Stashes drop down and couldn't remember if they had applied the stash or not. Could they see a history entry that shows that they applied "xxxx" stash a month ago?
Or is the only option to view these changes in a history to use the Git Bash Terminal for their stash and pop/apply commands so that they will show up in a git reflog command?

XCode Git Head Detached

I'm new to programming so please dont bite my head off! I'm using Xcode with GitHub, but it's suddenly stopped working. Xcode is not showing the current branch on source control, it doesnt load remote repositories, and the git status is 'head detached'.
I've gone to the command line and done 'sudo git --version', and accepted the new license.
This project is for fun, but I've put a lot of work into it. I don't mind just losing the history of the project if need be, I'd just like to get GitHub's source control back to a working state. Any suggestions?
If you want to add commit with detached head to any branch you should use cherry-pick command
git checkout "branchname"
git cherry-pick "commitnumber"
Your screenshot is showing that you checked out a specific commit. The long hexadecimal number partially obscured by the red line in the screenshot is the commit number. When you check out a specific commit, you don't have a current branch so the git head is detached.
The fix is to check out a branch so you have a current branch again. Select a branch inside the Branches folder, the BrianTests branch in your screenshot, right-click, and choose Checkout.

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.

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

Git (TortoiseGit) - How to revert a single file to a previous revision and then undo the revert?

When using Git with TortoiseGit: Does somebody know how to revert a single file(or a complete repository) to a previous revision?
For example I have a repository containing multiple files. One file exists in three revisions (1 ; 2 ; 3). Now I want to change from revision 3 back to 2.
TortoiseGit offers a "Revert" function in the "Show log" dialog which allows to jump back to a specific revision, but this will revert your whole repository instead of a single file.
Also once I have reverted something, I don't have a clue how to undo the revert and jump back to the newest revision.
From the command line: git checkout is probably what you want.
The documentation shows an example of:
$ git checkout master~2 Makefile
to revert Makefile to two revisions back in the master branch
From within TortoiseGit (via Windows Explorer) it looks like you can do this with the following steps:
Navigate in Explorer to the folder where the file is.
Right-click on the file you want to revert, choose Show log from the TortoiseGit context menu
In the top section ("graph") select the revision that has the version of the file you want to revert to
In the third section (file list) right-click the file and choose Revert to this revision
You should get a message like 1 files revert to e19a77
It is also possible to get a specific file:
Right-click on the file
Choose the menu item: Git Show Log
TortoiseGit show a dialog with a list of all revisions
Click on the prior revision (2)
In a list in the bottom of the dialog it shows all the files associated with the commit
Find the file you are looking to view
Right-click on that file and Save Revision To
This will save that previous revision of the file with the commit number concatenated on the file
For example:
- original file is file.txt
- revision 2 will save as file-67b51a8.txt
I'm using TortoiseGit v2.2.0.0
In TortoiseGit the answer is to right-click the project folder and click Show Log, then right-click the change you want to roll back to and click Switch/Checkout to this... . It will let you then proceed from that weird place in the commit stack, or branch in case you plan to commit and want things to stay sane.
Updated my answer, based on these comments:
by Alexander.
by mlibby
by Chris Moschini
Suppose the working tree is clean and you want:
Checkout some file(s) of its previous revision
Testing
Revert to current revision
Checkout some file(s) of its previous revision
(a) Right click the file you want to revert and Show Log for that file
(b) Right click the file in file list and perform Revert to parent revision
(c) repeat (a), (b) until you get all files you want.
Testing
Revert to current revision
(a) perform Revert... in context menu of explorer
This way, you can choose the file(s) you want to revert.
(b) or this quick way: perform Reset Hard in Log dialog
This way, all changed files revert. (=> Lost all working dir changes)
(Tested on TortoiseGit 1.8.16.1, GfW 2.6.4.windows.1, Win 10 64bit)
For Tortoise Version 2.3.0:
You can do it in several ways, but fastest i think is that:
Right click on the file
Click the menu option "Diff with previous version"
Right click on the left (previous) version of file
Click the menu option "Use this whole file"
Save the changes (ctrl+s)

Resources