Difference between revisions of "Git"

From Ittichai Chammavanijakul's Wiki
Jump to navigation Jump to search
(Created page with "== Git == Git is an open-source, distributed version control repository system. http://git-scm.com/ == Installing Git == http://progit.org/book/ch1-4.html == Installing Git on...")
 
 
(4 intermediate revisions by the same user not shown)
Line 8: Line 8:
  
 
== Installing Git on Windows ==
 
== Installing Git on Windows ==
http://code.google.com/p/msysgit
+
* http://code.google.com/p/msysgit
https://github.com/msysgit/msysgit/wiki/InstallMSysGit
+
* https://github.com/msysgit/msysgit/wiki/InstallMSysGit
http://code.google.com/p/msysgit/downloads/list
+
* http://code.google.com/p/msysgit/downloads/list
  
- Download Installer and run it.
+
* Download Installer and run it.
- Choose all default settings (for now).
+
* Choose all default settings (for now).
 +
 
 +
== Repository ==
 +
Launch Git Gui.
 +
 
 +
Create New Repository.b
 +
 
 +
Specify path.
 +
 
 +
== Syntaxes ==
 +
* Cretae an alias for check out.
 +
<pre>
 +
$ git config --global alias.co checkout
 +
</pre>
 +
 
 +
* Set the default editor.
 +
<pre>
 +
$ git config --global core.editor notepad++.exe
 +
</pre>
 +
 
 +
* Initialize git for the first time.
 +
 
 +
<pre>
 +
$ cd first_app
 +
$ git init
 +
Initialized empty Git repository in ../Rails_Projects/first_app/.git/
 +
 
 +
</pre>
 +
 
 +
* Add the ignore list.
 +
<pre>
 +
$ cd first_app
 +
$ vi .gitignore
 +
$ cat .gitignore
 +
.bundle
 +
db/*.sqlite3*
 +
log/*.log
 +
*.log
 +
/tmp/
 +
doc/
 +
*.swp
 +
*~
 +
.project
 +
.DS_Store
 +
</pre>
 +
 
 +
* Add all
 +
<pre>
 +
$ git add .
 +
</pre>
 +
. = Current directory
 +
 
 +
* Check status
 +
<pre>
 +
$ git status
 +
</pre>
 +
 
 +
* Commit
 +
<pre>
 +
$ git commit -m "Initial Commit"
 +
</pre>
 +
-m = Message
 +
git commit = Local commit
 +
git push = Sync up with remote repository
 +
 
 +
* View log
 +
<pre>
 +
$ git log
 +
commit 217d58e0f073e9249cca5ae1e05322340abd5034
 +
Author: Chris
 +
Date:  Mon Jan 30 17:05:03 2012 -0600
 +
 
 +
    Initial Commit
 +
 
 +
~/Documents/Rails_Projects/first_app (master)
 +
</pre>
 +
 
 +
* Restore the deleted file
 +
<pre>
 +
$ rm -rf *.rb
 +
 
 +
$ git status
 +
# On branch master
 +
# Changes not staged for commit:
 +
#  (use "git add/rm <file>..." to update what will be committed)
 +
#  (use "git checkout -- <file>..." to discard changes in working directory)
 +
#
 +
#      deleted:    application_controller.rb
 +
#
 +
no changes added to commit (use "git add" and/or "git commit -a")
 +
 
 +
$ git co -f
 +
 
 +
$ ls
 +
03/01/2012  02:37 PM                80 application_controller.rb
 +
 
 +
</pre>
 +
 
 +
== Github ==
 +
Coming soon

Latest revision as of 15:51, 1 March 2012

Git

Git is an open-source, distributed version control repository system.

http://git-scm.com/

Installing Git

http://progit.org/book/ch1-4.html

Installing Git on Windows

  • Download Installer and run it.
  • Choose all default settings (for now).

Repository

Launch Git Gui.

Create New Repository.b

Specify path.

Syntaxes

  • Cretae an alias for check out.
$ git config --global alias.co checkout
  • Set the default editor.
$ git config --global core.editor notepad++.exe
  • Initialize git for the first time.
$ cd first_app
$ git init
Initialized empty Git repository in ../Rails_Projects/first_app/.git/

  • Add the ignore list.
$ cd first_app
$ vi .gitignore
$ cat .gitignore
.bundle
db/*.sqlite3*
log/*.log
*.log
/tmp/
doc/
*.swp
*~
.project
.DS_Store
  • Add all
$ git add .

. = Current directory

  • Check status
$ git status
  • Commit
$ git commit -m "Initial Commit"

-m = Message git commit = Local commit git push = Sync up with remote repository

  • View log
$ git log
commit 217d58e0f073e9249cca5ae1e05322340abd5034
Author: Chris
Date:   Mon Jan 30 17:05:03 2012 -0600

    Initial Commit

~/Documents/Rails_Projects/first_app (master)
  • Restore the deleted file
$ rm -rf *.rb

$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       deleted:    application_controller.rb
#
no changes added to commit (use "git add" and/or "git commit -a")

$ git co -f

$ ls
03/01/2012  02:37 PM                80 application_controller.rb

Github

Coming soon