Skip to content

Commit b87b78d

Browse files
committed
Update git doc notes
- Convert to Markdown. - Add an example of using `git grep` with exclude pathspecs and `git ls-tree`.
1 parent 372f6d7 commit b87b78d

File tree

2 files changed

+84
-47
lines changed

2 files changed

+84
-47
lines changed

docs/git/git-git.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
### Creating a local repository for gitorious and pushing back to gitorious
2+
```
3+
$ git clone <url> <project>
4+
$ cd <project>
5+
# Git needs a file to commit.
6+
$ touch .gitignore
7+
$ git add .
8+
$ git remote add origin <url>
9+
$ git push origin master
10+
```
11+
12+
### Fork a github repository on gitorious
13+
```
14+
$ git clone <gitorious-url>
15+
$ git remote add origin <gitorious-url>
16+
$ git remote add upstream <github-url>
17+
$ git pull upstream
18+
$ git push -u origin master
19+
```
20+
21+
### Pulling / merging from an upstream git repo
22+
```
23+
$ git pull upstream
24+
$ git merge upstream
25+
# Resolve conflicts if needed
26+
$ git push master
27+
```
28+
29+
### How do I clone a remote branch with git?
30+
```
31+
$ git checkout -b <branch> remotes/origin/<branch>
32+
```
33+
34+
http://book.git-scm.com/4_undoing_in_git_-_reset,_checkout_and_revert.html
35+
http://stackoverflow.com/questions/2389361/git-undo-a-merge
36+
37+
Dumping an old repository to a new repository under a subdirectory, maintaining
38+
all of the commit history:
39+
40+
### Dump all patches for the commits from the start of time to `HEAD`
41+
```
42+
$ cd /old/checkout
43+
#
44+
# NB: this might be really funky with binary files or may not work; git-lfs's highly
45+
# encouraged!
46+
$ git format-patch --root HEAD
47+
```
48+
49+
### Import all commits maintaining core commit metadata/authorship
50+
51+
**Note:** This doesn't maintain committership, unfortunately.
52+
```
53+
$ cd /new/checkout
54+
# Start fresh
55+
$ git am --abort
56+
$ git reset --hard
57+
# Apply all patches in sequence; abort if needed
58+
$ find -s /old/checkout/ -name \*.patch -exec git am --directory=new/subdir {} \;
59+
[ $? -ne 0 ] && git am --abort
60+
```
61+
62+
### List all files tracked by git on HEAD under the include/ directory
63+
```
64+
$ git ls-tree -r --name-only HEAD include/
65+
```
66+
67+
### List all files with DEPRECATED using exclude pathspecs in `git grep` call
68+
69+
List all files that fit the following criteria using `git grep`:
70+
- contain the string "DEPRECATED"
71+
- tracked by git on HEAD.
72+
- that don't end with the following extensions under include/:
73+
- .c
74+
- .md
75+
- .pl
76+
- .pod
77+
```
78+
$ git grep -lEe DEPRECATED \
79+
':(exclude)*.c' \
80+
':(exclude)*.md' \
81+
':(exclude)*.pl' \
82+
':(exclude)*.pod' \
83+
include/
84+
```

docs/git/git-git.txt

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)