Skip to content

Commit 1620529

Browse files
CPTS notes
1 parent e5c5ca8 commit 1620529

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

docs/git.md

+7
Original file line numberDiff line numberDiff line change
@@ -180,30 +180,37 @@ To push our local changes into the connected github repo:
180180
```bash
181181
git push -u origin main
182182
```
183+
183184
Note: origin references the connection, and main is because we are in the main branch (that's what we are pushing). The first git push is a little different from future gitpushes, since we'll need to use the -u gflag in order to set origin as the defaulto remote repository so we won't have to provide its name every time.
184185

185186
### Some tricks
186187

187188
#### Counting commits
189+
188190
```
189191
git rev-list --count
190192
```
193+
191194
If you want to specify a branch name:
195+
192196
```
193197
git rev-list --count <branch>
194198
```
195199

196200
#### Backing-up untracked files
197201
Git, along with some Bash command piping, makes it easy to create a zip archive for your untracked files.
202+
198203
```
199204
$ git ls-files --others --exclude-standard -z |\
200205
xargs -0 tar rvf ~/backup-untracked.zip
201206
```
202207

203208
#### Viewing a file of another branch
209+
204210
Sometimes you want to view the content of the file from another branch. It's possible with a simple Git command, and without actually switching your branch.
205211

206212
Suppose you have a file called README.md, and it's in the main branch. You're working on a branch called dev: git show main:README.md
213+
207214
```
208215
git show <branchName>:<fileName>
209216
```

0 commit comments

Comments
 (0)