Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Tuesday, November 3, 2015

Git credential store

If your online git server does not allow ssh (like Microsoft Visual Studio Online), you can store git credentials in a file (not safe)

git config credential.helper store
see https://git-scm.com/docs/git-credential-store

Friday, September 18, 2015

More git commands

git remote show origin
* remote origin
  URL: git://github.com/rails/rails.git
  Remote branch merged with 'git pull' while on branch master
    master
  Tracked remote branches
    1-2-stable 2-0-stable 2-1-stable 2-2-stable 3-0-unstable master

$ git ls-remote --heads origin
5b3f7563ae1b4a7160fda7fe34240d40c5777dcd  refs/heads/1-2-stable
71926912a127da29530520d435c83c48778ac2b2  refs/heads/2-0-stable

$git log --decorate=full
$git log --decorate=full --pretty=oneline

#If I made a hard reset to a previous commit (but I had already pushed last commit), then I have to make a forced push:

$git reset --hard a9355ba42f5418c
$git push origin HEAD --force  #Erases in the online server the last commit

Thursday, August 27, 2015

Adding source to an empty remote git account

Set up your local directory

Set up Git on your machine if you haven't already.
mkdir /path/to/your/projectcd /path/to/your/projectgit initgit remote add origin git@bitbucket.org:xxx/xxx.git

Create your first file, commit, and push

git commit -m 'Initial commit with contributors'git push -u origin master

Thursday, March 12, 2015

git pulling the upstream changes (repo forked from Github)

First set the upstream repo (done only once)
git remote add upstream git://github.com/pjhyett/github-services.git
Then everytime you want to pull/fetch

git fetch upstream
or

git pull upstream


Wednesday, May 29, 2013

Pushing/pulling a specific branch between local and remote repository

from http://www.mariopareja.com/blog/archive/2010/01/11/how-to-push-a-new-local-branch-to-a-remote.aspx

git push -u origin plugin
 
This tells git to push changes from your plugin branch to the plugin branch on the origin repository. If origin does not have a plugin branch, it is created on the fly. The -u tells git that you want to be able to easily push and pull changes to that branch in the future.

 To perform the opposite, to pull a repo other than master,  use:

git checkout -b experimental origin/experimental

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