Git

From HackerNet
Revision as of 22:12, 1 January 2016 by Helikopter (talk | contribs)
Jump to: navigation, search

Git är ett versionshanteringsprogram som är gratis och open source. Det skapades 2005 för att hantera källkoden till Linuxkärnan.

Installation

sudo apt-get install git-core

Konfiguration

Status

git status

Repo

Skapa nytt lokalt repo,

mkdir ~/reponame && cd ~/reponame
echo "reponame" >> README.md
git init
git add README.md
git commit -m "first commit"

Klona repo

git clone https://github.com/username/reponame.git

Branch

Skapa en ny branch

git checkout -b NAME

Byt till en annan branch

git checkout NAME

Kolla branches

git branch

History

git log

GitHub

Author name and email address

git config --global user.name "Skeletor"
git config --global user.email "user@hackernet.se"

Connect local repository to a remote server, add the server to be able to push to it

git remote add origin https://github.com/user/reponame.git
git remote -v
git push -u origin master

Password cache

git config --global credential.helper cache
git config --global credential.helper 'cache --timeout=3600'