Uncommited files in git repo: how to reject local changes

It has happened to me a few times: I do local changes and test stuff locally. Then I come back a while later (weeks) and I have forgotten what were the changes for. In order to play it safe, I want to reset my local files to what is there on the github repo, so here is the solution


git fetch --all
git reset --hard origin/master

 Thanks RNA!

DropBox and GitHub: fatal: Reference has invalid format: ‘refs/heads/master

I am keeping all my code in a DropBox synchronized folder.

Besides, I keep the code in GitHub.

Well, this seems a bit redundant, but I prefer to do so because coding is an important part of my business.

But recently I experienced a problem and I want to share it with you.

I had to reformat my hard drive because of file corruption problems that could not be solved otherwise. But before I reformatted I was able to copy the files to an external hard drive. This was in a Mac OS X 10.7 Mountain Lion environment running on MacBook Pro 13”. I had to use Recovery Mode to do so.

Because I had 50+ Gbytes in DropBox, I decided to copy the info from the back-up drive to the new drive, so I did not have to wait ages to get the 700k+ files in my DropBox. And everything was fine until I realised that the local version was more recent than the DropBox one. This happened because at the time of losing my hard drive, the files in DropBox were not fully synchronised, so the local version was more recent. What I would not expect from DropBox is that it considers the on-line version to be the correct one even if the local is more recent. It should ask at least! 

How did I notice the problem? 4 days after the crash, the files finally downloaded from DropBox and replaced the local versions without asking. I think that DropBox should have a professional mode, more similar to git, where you can decide what you do in case of conflict.

So I was not able to do git pull in my code because the local HEAD did not mach the github HEAD. I was getting this error 

fatal: Reference has invalid format: ‘refs/heads/master 

Solution: I renamed the folder and created a new one from the backup hard drive. Now it seems to survive to DropBox synchronization!

GIT and GitHub: how to avoid entering credentials every time

Do you have some repos and have to enter the credentials everytime you connect to github? the solution is given here:


It is caused because you referred to the https instead of the git address. So you will have to do the following:

git remote set-url origin git@github.com:username/repo.git

about git error messages

the first time you push your local repo to a remote repo (f.e. github) if you get this message:

error: src refspec master does not match any.
error: failed to push some refs to 'git@github.com:xxx/yyy.git'

it’s because you forgot to make your first commit!

Pretty simple, yeah, but the literal of the error message it’s a bit difficult to “decipher” so I decided to write a quick note in case this helps you…

How to work with the console and github ruby projects

How to work on the console when you have a ruby project you want to try? If you are tweaking the code I believe that gem install … is not the solution.

So, I found a solution here: http://stackoverflow.com/questions/5424905/automatically-load-projects-environment-to-irb

What you can do is 

irb -Iname_of_libfolder -rname_of_rb_file

for example for me that was irb -Ilib -rwp_rpc