Sunday, March 11, 2012

Some beginner tricks with git

#################################################
Problem : error: Your local changes to the following files would be overwritten by merge: rfiles/BiOpticaR/Various/spacetime_ISIN.R
Please, commit your changes or stash them before you can merge.Aborting
#################################################
$ git pull
remote: Counting objects: 38, done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 25 (delta 13), reused 1 (delta 0)
Unpacking objects: 100% (25/25), done.
From ssh://ekumen/home/acizmeli/GIT
   d63ba8f..cea6b9e  master     -> origin/master
Updating d63ba8f..cea6b9e
error: Your local changes to the following files would be overwritten by merge:
    rfiles/BiOpticaR/Various/spacetime_ISIN.R
Please, commit your changes or stash them before you can merge.
Aborting

Solution:
$ git reset --hard HEAD
HEAD is now at d63ba8f Moved all netcdf imagery functions in the fil......
$ git pull

#################################################
Problem :  Push rejected
! [rejected]        master -> master (non-fast forward)
error: failed to push some refs to.....
#################################################
Solution:
(From http://rip747.wordpress.com/2009/04/20/git-push-rejected-non-fast-forward/)

When trying to do a push to a repo, you might encounter the following error:
$ git push github master
To git@gitproxy:rip747/cfwheels.git
! [rejected]        master -> master (non-fast forward)
error: failed to push some refs to ‘git@gitproxy:rip747/cfwheels.git’
Don’t panic, this is extremely easy to fix. All you have to do is issue a pull and your branch will be fast-forward:
$ git pull github master
From git@gitproxy:rip747/cfwheels
* branch            master     -> FETCH_HEAD
Already uptodate!
Merge made by recursive.
Then retry your push and everything should be fine:
$ git push github master

#################################################
Problem : Automatic merge failed; fix conflicts and then commit the result.
#################################################
use :
git mergetool

No comments:

Post a Comment