Difference between revisions of "Git"
Jump to navigation
Jump to search
(2 intermediate revisions by the same user not shown) | |||
Line 16: | Line 16: | ||
== Repository == | == Repository == | ||
− | Launch Git Gui | + | Launch Git Gui. |
− | Create New Repository | + | Create New Repository.b |
− | Specify path | + | Specify path. |
== Syntaxes == | == Syntaxes == | ||
− | * Cretae an alias for check out | + | * Cretae an alias for check out. |
<pre> | <pre> | ||
$ git config --global alias.co checkout | $ git config --global alias.co checkout | ||
</pre> | </pre> | ||
− | * Set the default editor | + | * Set the default editor. |
<pre> | <pre> | ||
$ git config --global core.editor notepad++.exe | $ git config --global core.editor notepad++.exe | ||
</pre> | </pre> | ||
− | * | + | * Initialize git for the first time. |
<pre> | <pre> | ||
Line 42: | Line 42: | ||
</pre> | </pre> | ||
− | * Add the ignore list | + | * Add the ignore list. |
<pre> | <pre> | ||
$ cd first_app | $ cd first_app | ||
Line 57: | Line 57: | ||
.project | .project | ||
.DS_Store | .DS_Store | ||
+ | </pre> | ||
+ | |||
+ | * Add all | ||
+ | <pre> | ||
+ | $ git add . | ||
+ | </pre> | ||
+ | . = Current directory | ||
+ | * Check status | ||
+ | <pre> | ||
+ | $ git status | ||
</pre> | </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.
Installing Git
http://progit.org/book/ch1-4.html
Installing Git on Windows
- http://code.google.com/p/msysgit
- https://github.com/msysgit/msysgit/wiki/InstallMSysGit
- http://code.google.com/p/msysgit/downloads/list
- 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