User Tools

Site Tools


Sidebar



git

Table of Contents

Git

fatal: unable to access 'C:\Users\User/.gitconfig': Permission denied

the HOME env variable might be wrong. Try

set HOME

and fix it if needed by setting it to the right value or by removing it:

set HOME=c:\Users\YOUR_USER_NAME
rem OR: set HOME=

flow for switching branches, removing untracked files, updating submodules

Warning: this will remove ALL untracked files and directories!!

git checkout master
git clean -xfdf     # be careful with this!
git checkout OtherBranchWithSubmodules
git submodule update --init --recursive

remove all untracked files and folders including everything in .gitignore

git clean -xfdf

create alias for clone recursive

in ~/.gitconfig

[alias]
        clr = clone --recursive

graphical interface for git

set remote url

git remote set-url origin "git@github.com:USER/REPO.git"

info about remote url

git remote -v

How to commit my current changes to a different branch in git

git stash
git checkout other-branch
git stash pop

code completion for git

sudo port install git-core git-extras

undo 'git add' before commit

git reset FILE

create a new branch

git checkout -b Demo

een branch pushen die remote nog niet bestaat

git push --all

move subdir to separate git repo

clone specific branch recursively

git clone --recursive -b BRANCHNAME git@github.com:..../.....git

compare two commits

git diff HEAD HEAD~
git diff HEAD HEAD~~

show all branches (local and remote)

git branch -a

show remote branches

git branch -r

clone a specific branch

git clone -b experimental git@github.com:companje/ofxArcText.git

existing repo

cd existing_git_repo
git remote add origin https://github.com/Doodle3D/Doodle3D.git
git push -u origin master

change url of remote origin

git config remote.origin.url git@github.com:USER/PROJECT.git

open git config in editor

git config -e

git remote update

a git remote update followed by a git diff shows the changes you will get for a git pull

git pull

is a combination of git fetch and git merge

force a push

git push -f origin RicksVersie

show branches with more information

git branch -av

show listing of commits

git reflog

move a branch

git branch -m master RicksVersie
git branch -m PetersVersie master

delete a local branch

git branch -D crazy-idea

rename a local branch

git branch -M oldname newname

git with colors

git config --global color.ui true

rollback /revert to last commit

not tested yet. more info

git reset --hard HEAD

merge a branch into another branch

git checkout experimental
git merge master

merge specific files/folder from another git branch

#You are in the branch you want to merge to
git checkout <branch_you_want_to_merge_from> <file_paths...>

read more

git (on github) keeps asking for password when using pull or push

You might have cloned the project over https. Check if this is the case using

git config -l

now change the remote origin to:

git config remote.origin.url git@github.com:USER/PROJECT.git

verwijder de 'Leiden' branch op de remote

git push origin :Leiden

verwijder een folder uit de cache

(niet uit je directory structuur)

git rm -r --cached libs/

git push origin NAME

als je een nieuwe branch hebt gemaakt op een andere computer dan moet je die branch nog handmatig pushen naar remote met:

git push origin NAME

If you are just after tracking someone else's project, this get you started quickly

git clone url = svn checkout url
git pull = svn update

git clone depth

git clone git://github.com/openframeworks/openFrameworks.git –depth 1

GIT gui programs

By default a couple of GUI programs are installed with git, for browsing through history and committing etc.

gitk
git gui

you might first need to run sudo apt-get install gitk

OSX git GUI's

open git config editor

git config -e

this opens the file .git/config
if this not works because of an error in .git/config just open the file with nano:

nano .git/config

In je repository kun je zo iets pushen naar de server (bijv. github)

cd addons_rick/
git add ofxArcBall/
git commit -am "added ofxArcBall"
git push origin master

checkout

to go back to a revision:

git checkout revisionid

to bring the repository back to it's most recent state

git checkout master

Set up git

  git config --global user.name "Your Name"
  git config --global user.email your@emailaddress.com

Get started with a newly created github repository

  mkdir PROJECTNAME
  cd PROJECTNAME
  git init
  touch README
  git add README
  git commit -m 'first commit'
  git remote add origin git@github.com:YOURUSERNAME/PROJECTNAME.git
  git push -u origin master

creating new remote git repository

git init
or
git --bare init

Permission denied (publickey)

You might be cloning a non-anonymous repository from github. If you just started using github (on your machine) github first needs to trust you. You can add the contents of ~/.ssh/id_rsa.pub to the SSH public key list on github at your account settings. If you don't want that just clone the repository through https or readonly.

Some very usefull info about ssh keys etc: http://help.github.com/ssh-issues/

Create id_rsa files with ssh-keygen

just run ssh-keygen

Adding your public key to the server to remember your git user's password

scp ~/.ssh/id_rsa.pub user@remote.example.com:/tmp/id_rsa.pub
mkdir ~/.ssh
chmod 700 ~/.ssh
cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys

interesting article

A successful Git branching model » nvie.com
http://nvie.com/posts/a-successful-git-branching-model/

uitchecken van git project op onze server

hiervoor hebben we rick aan de 'git' groep toegevoegd met 'usermod -a -G git rick'. Harmen deed ook nog iets met 'chgrp'

git clone rick@git.giplt.nl:/home/giplt/git/datamining

Nieuw git project opzetten op onze server

ssh username@giplt.nl
cd git
mkdir newproject
cd newproject/
git --bare init

automatically pull from master

if you get this message:

If you often merge with the same branch, you may want to
configure the following variables in your configuration
file:
 
    branch.master.remote = <nickname>
    branch.master.merge = <remote-ref>
    remote.<nickname>.url = <url>
    remote.<nickname>.fetch = <refspec>

open the .git/config file (ie. by git config -e) and set the branch.master.remote to origin and the branch.master.merge to refs/heads/master

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
 
[remote "origin"]
        url = rick@companje.nl:/home/rick/git/Globe4D-base
        #fetch = +refs/heads/*:refs/remotes/origin/*
        fetch = refs/heads/master

Eenmalig git configureren voor multi user repositories op de server

(for the record, want is nu al gedaan)
Dit zorgt er voor dat bij een commit de gepushde files als group niet de userid krijgen van degene die een bestand heeft aangemaakt, maar de gedeelde group (bij ons 'git') waarbinnen iedereen schrijfrechten heeft.

sudo chmod -R g+ws *
sudo chgrp -R mygroup *
 
git repo-config core.sharedRepository true

remove origin from remote

git remote rm origin

git add

first do a git –bare init on the server

git remote add origin {url}

change editor for git

git config --global core.editor "nano"

in case of this error:

error: src refspec master does not match any.
error: failed to push some refs to ..

you're commit might went wrong or you just forgot to commit:

git commit -m 'first commit'

submodules in a project

see this page

add submodule to a project (this means to clone another repo into a subfolder of your repo)

git submodule add git://github.com/test/test.git subfolder/test
git submodule update --init

remove a submodule

git rm --cached folder/submodule

you can also clone your repo recursively, that way also submodules are cloned.

git clone --recursive http://server/repo.git

pull git submodules

see the git book

git submodule init
git submodule update

nog niet getest:

git submodule update --init --recursive

remove traces of wrongly removed submodules

git config -e
rm -rf .git/modules/*

fatal: Needed a single revision

cloning probably resulted in an empty folder. Delete the folder and try to clone again.

useful git commands

git list files

git ls-files

git cheat sheet

git.txt · Last modified: 2014/11/24 09:46 by rick