Accidentally removed stash in Github Desktop - Don't know how to get it back - github

I meant to stash my changes so I could see what my project was like before my changes, but when I went to bring it back I had accidentally overridden my stash. Not sure if it can be brought back.
I tried 'git fsck --unreachable', but there is a lot to sort through and I didn't see it anywhere
Up late trying to fix it, any help would be appreciated so I don't have to pull an all-nighter to redo my work.

Related

Regarding GitHub and version control

Recently, we have started a group project and decided to use GitHub to share the code among ourselves.
For example, if I created a login page and my friend created a home page, how can I get it on my local machine.
I mean, whenever a change is made to the repo, do we need to download it all again?
The beauty of GitHub is that you can always go back whenever you feel like.
Whenever a changed is made by any of the teammate, it's a really good practice that you push that change. Even when it's a small one. After you've pushed your changes, your teammates would need to pull that change.
The best sequence for this is;
- git commit
- git pull
- git push
You'll have to pull the changes first as it would help you avoid getting merge conflicts. If you get any merge conflicts on any line, or any function, you'll resolve that conflict and follow the same sequence once again.
So, to conclude, GitHub is so easy to use and you won't have to necessary 'Download' all the changes once again. I would recommend you to setup via Visual Studio 2019 so that it becomes easier for you to just "pull" the changes whenever a new change has been made.

Lost 2 weeks worth of progress by clicking 'Checkout' in Xcode source control, is there any way to recover it?

I admit that I have very little experience with source control and git, however, in my past projects it has been useful to make commitments as backups. During this project, I decided to test out making a new branch. After working in it I decided to click 'checkout' master not knowing what it really did, now all my commits 2 weeks prior have been deleted, it's like I traveled back in time and all those commits I made never existed. All the files I had been working on are now gone and nowhere to be seen. I searched trash, I searched the project folder. They vanished. Did I screw up? Is there any way to recover this files? I searched all the branches without any luck. Thanks.
I don't know how Xcode's UI spells it, but the git command is git checkout #{1}. Look up reflogs and revisions, #{1} is how git spells "what I had checked out just before I did whatever just changed it".
Did I screw up?
Not necessarily! If you made commits on the new branch, everything is still there, on the new branch you created and worked on. So just checkout that branch again, and it will return!
now all my commits 2 weeks prior have been deleted
Ah, so you did make commits. In that case, be assured, nothing is lost.
But if you did not commit on the new branch — if you checked out master without committing your work from the new branch you were working on — then yes, you screwed up and it is all gone. The substance of git is commits, and whatever is not committed is not in the purview of git and is subject to unexpected loss. Loss due to checkout is a classic git trap; you would think it would warn you of the danger, but it doesn’t always do that.

Weird SourceTree commit bug

I'm using Source Tree, and I ran into extremely weird bug:
I have a problem with a "ghost" unstaged file to commit, that just wont go away:
When I try to commit it it does nothing, it wont even move into staged files.
It shows even right after downloading into a brand new repo from remote where the bug is not present.
I tried clearing all cache with Ccleaner, did not help. I also just deleted the file, which fixed the issue, then I returned the file back (without any changes), and the ghost commit returned...
It's super annoying, as it wont let me leave any branch I create, keeps on telling me I have uncommited changes even though I do not.
The change that keeps on poping up is very simple thing that was already implemented into remote. I would provide any more detail or info but not sure what to post. This is how it looks like, ALWAYS after a fresh branch is created:
Any idea how do I make this thing go away? It drives me crazy, thanks
EDIT:
Found the main problem, I had the same file twice on main remote, one capitalized the other one not: https://prnt.sc/pe6nwz Damn...

How to delete a line of code from a commit that is pushed into the github?

So it happened that I accidentally added an empty line of code and I need to remove it, but how to do it, how to kill it?
delete that line from your local master branch.
Push it to origin master after you commit it.
ta da.
I suggest you read this article to see how to do it, and why you shouldn't.
In short
Make a new commit is easier
Reverting the commit as a new commit is not that hard either
You can do it, but you'd better get it right, and other developers won't like you
As an aside, this sounds like a bad place to work if this has caused an issue. Git is meant to show you this history of what everyone has done. Re-writing it defeats the point.

(Mercurial/tortoisehg) Lost commits - how to troubleshoot

A colleague of mine was working on a VS project this morning, which he claims was in a folder clone of our central repository. He built a release version of the application which is still there with the correct date/time stamp on it.
He then said he committed several times during this time, but at some point, he tried pulling down changes from the central repository and merge them in with his changes. He can't really remember what steps he took, but the end result is that all the changes he did to the source were lost. now, i'm trying to help him to see if we can recover any of those changes.
He told me after he committed his changes (several commits), He went into the tortoisehg workbench, pulled, and saw that there were many changes in the central repository. He decided to either "Merge with local" or "Update" to the tip pulled down - he can't remember which. I showed him the two dialogs, and asked him if he discarded changes, shelved or anything else. He couldn't remember, really, but he did remember he had to back out because tortoisehg didn't like what he was doing. Eventually, he did seem to be able to update to the repository tip.
I'm thinking that unless he physically deleted the folder in which he was working, and then got the latest, those commits he claimed to have done would have been recorded somewhere? What are common errors people do when pulling the remote repo? Are there any log files or history i can check to see if i can salvage or at least tell where he was working on this stuff?
any hints to troubleshoot this would be greatly appreciated.
First of all backup the tree somewhere including .hg and everything under it. Then...
hg heads
...to see if he's just lost track of his commits. If it's there, it's just a case of updating back to it and doing a proper merge.
hg log -u 'His Username'
...to see if the commits are anywhere in the repo. If they're are there you can then work forward from them.
hg shelve --list
...to see if he's managed to shelve things somewhere
Take a look in .hg/strip-backups, to see if he's managed to strip his changes somehow. Anything else destructive should have left backups in .hg too.
That should be a good start. If none of those give any clues then others may be able to suggest some things.
I don’t know about TortoiseHG, but usually the first thing would be to check hg out.