view · edit · history · print

GIT version control notes

Ref: OnlineGitRepositories

What is GIT? wikipedia, homepage

References:

git help <function>

New repository

 mkdir localgittest001
 cd localgittest001
 git init
   Initialized empty Git repository in .git/
 git config [--global] user.name "Ragnar Von Lodbrok"
 git config [--global] user.email ragnar@AT.lodbrok.be
 git config --global color.status auto
 git config --global color.branch auto
 git-config core.autocrlf true
   for GIT on CygWin only!
 git-config core.safecrlf true
   for GIT on CygWin only!
 vi .git/description
 vi .git/info/exclude
 vi .gitignore
 git add . 
   add all files recursively
   if no files exist you get the below message
     fatal: pathspec '' did not match any files
 git commit -m "initial commit of project"
   # On branch master
   #
   # Initial commit
   #
   nothing to commit (create/copy files and use "git add" to track)

commands

 git gui
 gitk --all
 git instaweb (use lighthttpd)

remove tracked GIT files

 echo "*.ignore" >> .gitignore
 cp file.rtf file.rtf.ignore # just to be absolutely sure
 git rm --cached file.rtf # cached normally only removes from index

Add and change file(s) with detailed output

 vi README.txt
 git status
   # On branch master
   #
   # Initial commit
   #
   # Untracked files:
   #   (use "git add <file>..." to include in what will be committed)
   #
   #       README.txt
   nothing added to commit but untracked files present (use "git add" to track)
 git add README.txt
 git status
   # On branch master
   #
   # Initial commit
   #
   # Changes to be committed:
   #   (use "git rm --cached <file>..." to unstage)
   #
   #	new file: README.txt
 git commit -m "create README.txt file"
   Created initial commit 6953b11: create README.txt file
   1 files changed, 1 insertions(+), 0 deletions(-)
   create mode 100644 README.txt
 git status
   # On branch master
   nothing to commit (working directory clean)
 vi README.txt
 git status
   # On branch master
   # Changed but not updated:
   #   (use "git add <file>..." to update what will be committed)
   #
   #	modified:   README.txt
   #
   no changes added to commit (use "git add" and/or "git commit -a")
 git diff
   diff --git a/README.txt b/README.txt
   index 2d00bd5..e5c5c55 100644
   --- a/README.txt
   +++ b/README.txt
    -1 +1,2 
    line one
   +line two
 # changing an creating some files...
 git status
   # On branch master
   # Changes to be committed:
   #   (use "git reset HEAD <file>..." to unstage)
   #
   #	new file:   dir1/f1
   #	modified:   notes.txt
   #
   # Untracked files:
   #   (use "git add <file>..." to include in what will be committed)
   #
   #	dir3/
 git commit -m "what do i commit?"
   Created commit 2111ef1: what do i commit?²
   2 files changed, 2 insertions(+), 0 deletions(-)
   create mode 100644 dir1/f1
 git-commit README.txt # add commit mesage to file .git/COMMIT_EDITMSG and save in default editor
   Created commit 9df3388: commit without adding
   1 files changed, 1 insertions(+), 0 deletions(-)

Test hosting clone project: http://github.com/therealtroll/testrepo001/tree/master

  
Global setup:
  git config --global user.email therealtroll@yahoo.com

Next steps:
  mkdir testrepo001
  cd testrepo001
  git init
  touch README
  git add README
  git commit -m 'first commit'
  git remote add origin git@github.com:therealtroll/testrepo001.git
  git push origin master

Existing Git Repo?
  cd existing_git_repo
  git remote add origin git@github.com:therealtroll/testrepo001.git
  git push origin master

Branching

 git checkout -b <topic> master # branch <topic> 
 work,work,work,commit to <topic>
 git checkout master
 git merge <topic> # merge into master
 git branch -d <topic> # delete branch <topic> if wanted

Alternative GUI interfaces:

Errors:

 “You have some suspicious patch lines”
   git-config core.autocrlf true 
   git-config core.safecrlf true
admin · attr · attach · edit · history · print
Page last modified on July 23, 2013, at 05:17 AM