| 1 |
GIT |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
Also note everything is case sensitive |
| 6 |
|
| 7 |
### Useful Resources: |
| 8 |
|
| 9 |
(http://www.kernel.org/pub/software/scm/git/docs/user-manual.html) |
| 10 |
(http://www.sourcemage.org/Git_Guide) |
| 11 |
(http://wiki.sourcemage.org/Git_Guide) |
| 12 |
(http://blog.neontology.com/posts/2007/10/17/git) |
| 13 |
(http://tomayko.com/writings/the-thing-about-git) |
| 14 |
http://www-cs-students.stanford.edu/~blynn/gitmagic/ |
| 15 |
|
| 16 |
### Installing |
| 17 |
|
| 18 |
<pre> |
| 19 |
# Change default Linux editor in ~/.bashrc: |
| 20 |
EDITOR=nano export EDITOR |
| 21 |
</pre> |
| 22 |
|
| 23 |
<pre> |
| 24 |
# Create a .gitconfig in ~ |
| 25 |
|
| 26 |
[user] |
| 27 |
name = Your Name Comes Here |
| 28 |
email = you@yourdomain.example.com |
| 29 |
</pre> |
| 30 |
|
| 31 |
<pre> |
| 32 |
# Create an ignore file (.gitignore) if not already in your project root |
| 33 |
|
| 34 |
# Ignore any file named foo.txt. |
| 35 |
foo.txt |
| 36 |
# Ignore (generated) html files, |
| 37 |
*.html |
| 38 |
# except foo.html which is maintained by hand. |
| 39 |
!foo.html |
| 40 |
# Ignore objects and archives. |
| 41 |
*.[oa] |
| 42 |
# Ignore directories |
| 43 |
log/* |
| 44 |
</pre> |
| 45 |
|
| 46 |
### Installing a remote repository |
| 47 |
|
| 48 |
http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way |
| 49 |
Under Ubuntu had to also add git to a new sshusers group to sshusers to AllowGroups in /etc/ssh/sshd_config, used webmin to add the user to groups and to restart ssh |
| 50 |
|
| 51 |
|
| 52 |
### Useful commands |
| 53 |
|
| 54 |
<pre> |
| 55 |
# To commit changes to local repo: |
| 56 |
git commit -a |
| 57 |
</pre> |
| 58 |
|
| 59 |
<pre> |
| 60 |
# To add a new file to local repo: |
| 61 |
git add <filename> |
| 62 |
|
| 63 |
# To add all new files to the local repo: |
| 64 |
git add . |
| 65 |
</pre> |
| 66 |
|
| 67 |
|
| 68 |
To see the changes: |
| 69 |
|
| 70 |
$ git diff --cached # difference between HEAD and the index; what |
| 71 |
# would be committed if you ran \"commit\" now. |
| 72 |
$ git diff # difference between the index file and your |
| 73 |
# working directory; changes that would not |
| 74 |
# be included if you ran \"commit\" now. |
| 75 |
$ git diff HEAD # difference between HEAD and working tree; what |
| 76 |
# would be committed if you ran \"commit -a\" now. |
| 77 |
$ git status # a brief per-file summary of the above. |
| 78 |
|
| 79 |
|
| 80 |
To update remote repo with changes: |
| 81 |
|
| 82 |
git push |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
To roll back the last commit |
| 90 |
|
| 91 |
git reset --soft HEAD^ |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
To reset local to origin: |
| 96 |
|
| 97 |
git reset --hard origin |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
To pulla single commit from similar repo: |
| 104 |
|
| 105 |
git pull git@gitorious.org:gitorious/dchelimskys-clone.git master:f38b5fc |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
Creating an archived version |
| 112 |
|
| 113 |
git tab v0.1 |
| 114 |
git archive --format=zip |