Difference between revisions of "Git"

From HackerNet
Jump to: navigation, search
Line 1: Line 1:
'''WIP'''
 
 
 
Git är ett versionshanteringsprogram som är gratis och open source. Det skapades 2005 för att hantera källkoden till Linuxkärnan.
 
Git är ett versionshanteringsprogram som är gratis och open source. Det skapades 2005 för att hantera källkoden till Linuxkärnan.
  
Line 11: Line 9:
  
 
===Repo===
 
===Repo===
Skapa nytt repo
+
Skapa nytt lokalt repo,
  mkdir ~/dev && cd ~/dev
+
  mkdir ~/reponame && cd ~/reponame
 
  echo "reponame" >> README.md
 
  echo "reponame" >> README.md
 
  git init
 
  git init
Line 19: Line 17:
  
 
Klona repo
 
Klona repo
  git clone https://github.com/USERNAME/REPONAME.git
+
  git clone https://github.com/username/reponame.git
  
 
===Branch===
 
===Branch===
 
Skapa en ny branch
 
Skapa en ny branch
 
  git checkout -b NAME
 
  git checkout -b NAME
 +
Byt till en annan branch
 +
git checkout NAME
 +
Kolla branches
 
  git branch
 
  git branch
 +
 +
===History===
 +
git log
  
 
=GitHub=
 
=GitHub=
Username
+
Author name and email address
  git config --global user.name "Programming"
+
  git config --global user.name "Skeletor"
 
  git config --global user.email "user@hackernet.se"
 
  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 add origin https://github.com/user/reponame.git
 +
git remote -v
 
  git push -u origin master
 
  git push -u origin master
  
Line 37: Line 43:
 
  git config --global credential.helper cache
 
  git config --global credential.helper cache
 
  git config --global credential.helper 'cache --timeout=3600'
 
  git config --global credential.helper 'cache --timeout=3600'
 +
 +
[[Category:Guider]]

Revision as of 23:12, 1 January 2016

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'