git

Git is a distributed version control and source code management (SCM) system.

http://git-scm.com/

SSH public key generation

Config

Create repository

Edit .gitignore #for Java

Sample .gitignore

*~
.metadata
*.class
*.jar
*.war 
*.ear 
*.zip
target/

Clone repository

Branch creation based on current branch

Commit to remote branch

Merge to other branch

Reapply .gitignore

Setup git server on RHEL

http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server

   1 sudo bash 
   2 adduser git
   3 su git
   4 cd
   5 mkdir .ssh
   6 cd .ssh
   7 git --version # git version 1.7.1
   8 
   9 #generate and paste the pub key from my user on local machine
  10 ssh-keygen -f id_rsa -p
  11 cat ~/.ssh/id_rsa.pub #local machine
  12 
  13 # in the git server
  14 cd .ssh # git account
  15 vim authorized_keys  #git server, paste the content of id_rsa.pub
  16 cd ~
  17 chmod 700 .ssh/
  18 chmod 600 .ssh/authorized_keys 
  19 ssh git@bitarus.allowed.org # test connection from local machine
  20 vim /etc/passwd #change shell for git user
  21 git:x:505:505::/home/git:/usr/bin/git-shell 
  22 
  23 # create project on git server
  24 cd /home/git
  25 mkdir hello.git
  26 cd hello.git
  27 git --bare init
  28 
  29 #create project on local machine
  30 cd ~
  31 cd gitRepository
  32 mkdir hello
  33 cd hello
  34 git init
  35 touch README
  36 git add .
  37 git commit -m 'initial commit'
  38 git config --list #check config
  39 git remote add origin git@bitarus.allowed.org:/home/git/hello.git
  40 git push origin master
  41 git log

Revert file to original

git (last edited 2016-02-27 00:23:41 by 123)