Discard all changes in Github Desktop (Mac) - github

How to discard all changes in Github desktop (mac), comparing to the latest commit?
It is possible to click on one file and select "discard changes". But how to discard all changes in files?

Just in case anyone is interested, it can be done via GitHub's Menu Bar: Repository/Discard changes to selected files.

Right click on any file and you'll find the option to 'Discard All Changes':

If anyone would be interested to do this without Github Desktop, since I got to this page by searching;
"How discard all changes work in Github Desktop?"
Just run the command below in your project folder from terminal:
git reset --hard

Use
git checkout .
to revert local changes and add a
git pull
to fetch the latest code from remote

Related

Accidently deleted every file in Vs Code while trying to push to git, any way to recover them?

I am a complete noob so while trying to deploy one of my programs to heroku, I needed to push it to github, in Vscode while trying to do that, I got a whole bunch of files that I didn't want to upload on github, so I hit remove all from this screen
I now realize that I deleted everything and I don't know what I can do, I tried going into my drive and hitting properties to try and restore but looks like I hadn't turned that feature on. Is there anyway I can recover my files? I am on windows
Simply go to your terminal and navigate to the folder you are pushing to git. You can run these commands:
git log --pretty=oneline (Shows all previous commits)
git checkout . (This resets everything to the previous commit)
Once you have reset your project to the previous commit, try again and delete the files you wanted to remove. Then perform the git commit -am "text here" and git push heroku master commands.
EDIT: This only works if you have already made git commits. If you have deleted everything and git log --pretty=oneline does not show any commits, then there is no way to recover the deleted files.
You can also check the recycle bin of your computer to see if the deleted files are there.

How to delete a file from GitHub history without using commandline

I need to remove a file from history. I don't have commandline access to GitHub. Kindly help if this can done through UI itself.
You can't delete the file from history, but you can delete it from the repository by following this help article
Alternatively, you could do a cherry-picking using one of the Git GUIs software, then cherry-pick all the commits, except for the one that you wanted to removed, into a new branch. Then, delete the old branch.
TO achieve this, you have to have command line access.
Delete file from history
But Using UI , you could delete the file from the repo (branch)
Ex:
Click the delete button on top right corner and commit.
You don't need command line access to GitHub, only to your own local clone, where you can:
either do a git filter-branch (example here)
or use BFG
Then you git push --force.
But the alternative, if you really don't want to use any command line, even locally... would be to contact GitHub support, asking them to remove the file from your remote repo history.
That is a last resort option though, since you are supposed to be able to do that on your own.

How to view file changes before pulling through GitHub on RStudio?

I'm transitioning from using Subversion in Eclipse for code management to GitHub in RStudio. It's starting to make sense, but I can't seem to figure out how to pull effectively.
Specifically, if I use the Pull arrow in RStudio, every file change in the repository automatically updates my local files without warning. I can see how many files were updated, but not what changed!
Here are the questions I'm hoping to get help with:
1) Can I preview the repository file changes in RStudio before I pull them locally? With SVN in Eclipse, there was an indicator showing files with a difference, and the option to view side by side.
2) If multiple files have been changed on the repository, is it possible to pull just 1 locally?
3) How can I revert a local file to a previous version?
Right now I've been trying to do this all within RStudio for simplicity. I haven't used things like the GitHub desktop client.
I appreciate the help!
I would suggest you better get used to the git's own tools to stay informed about your repository.
For example you could do following.
Before you pull, check your current commit logs
git log
This should show you how your current commits stack up. Note the latest commit id (first 4-5 letters would usually do)
Now after pulling you can see the difference using following command
git diff --color your_previous_commit_id..HEAD
If you don't like the changes and want to go back,
you can just reset to your favorite commit with following command. BTW run "git stash save" to keep a copy of your uncommitted changes.
git reset --hard you_favorite_commit_id
Note: that this will delete all your uncommitted changes unless you stashed them and put your local branch behind the remote repo branch you are tracking again.
Wondering where to put these commands? Check https://git-scm.com/downloads.
What's good about using these git tools is that if you switch between IDEs you don't need to search for same functionalities you had in your earlier IDEs.

Egit: Right click not showing GIT commands

I can't see the GIT commands when using right click on any files in a GIT repository.
I'm using Eclipse-Luna, A fresh install, afeter trying different versions of EGIT.
Thanks,
Elyahu
Some screen shots of the preferences:
I can't see the GIT commands when using right click on any files in a GIT repository.
You must first share that local project in order to make it recognized as a Git repository.
See "How make Eclipse/EGit recognize existing repository information after update?",but don't forget, once shared, to close/reopen your project.
Then Git will be active on said project.

Git commit not possible. There are no staged files

I am using EGits with Eclipse and running into some issues.
I have one change from head; I have made one new class.
When I right click on this class and click "push", the following dialog shows and I cannot get past it :
Anyway, I need to push this file because I can't commit in real life, and now I cannot commit in Eclipse either and it's taking it's toll mentally.
Thanks.
PS I have googled this extensively looking for an easy fix (like a "stage" button) and found nothing.
using EGit:
Right click it and navigate to Team => Add.
after then Push the code
Before pushing the file add that new file on git using terminal
git add after then
git push origin branch
OR you need to add to Index first before committing it.