-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgit-tips.Rmd
More file actions
86 lines (62 loc) · 2.51 KB
/
git-tips.Rmd
File metadata and controls
86 lines (62 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
title: "git-tips (skills)"
author: "Vishwesha Guttal"
date: "6 October 2015"
output: html_document
---
## Frequently used GIT commands
### Initialize, add, commit
* Go to the project directory and initlize git.
```{r eval=FALSE}
$ git init
```
* Now add files you want git to track.
+ If you want all files in the directory to be tracked, use: filenames = .
+ If you want only certain extensions to be tracked, use: filenames = *.desiredextension
+ If you want certain extensions to be ignored, create a file called .gitignore and list all extensions (preceded by *: for example, *.txt)
```{r eval=FALSE}
$ git add filesnames
```
* Commit the changes made for the added filenames
```{r eval=FALSE}
$ git commit -m "First commitment of life"
```
* Now, you can always check the status and logs of all commits with following commands.
```{r eval=FALSE}
$ git status
$ git log
```
### If you are behind a proxy
* If you are behind a proxy, visit [this link](http://nknu.net/git-through-proxy/) and follow the instructions to add proxy settings to git.
### Move files from computer to github webpage/login
* This following specific step is required only the first time. Move these files to the github server where your login name is gitlogin
```{r eval=FALSE}
$ git remote add origin git@github.com:gitlogin/git-tips.git
$ git push -u origin master
```
* If you now go to http://github.com/gitlogin, you must find your files there!
### Clone a repository from github webpage to computer
* Follow this link: https://help.github.com/articles/cloning-a-repository/
### Move changed files from computer to webpage
* If you make changes to your files, then the following commands will update the files locally.
```{r eval=FALSE}
$ git add modifiied-filenames
$ git commit -m "Write key summary of changes here"
```
* Now move it to server
```{r eval=FALSE}
$ git pull -u origin master
$ git push -u origin master
```
* In the above, we first pulled before pushing our changes because if we have collaborators, then those changes must be updated on our files first.
* When we frequently want to update, we can combine a few commands in one go
```{r eval=FALSE}
$ git add . && git commit -m "Add message here" && git pull -u origin master
$ git push -u origin master
```
### Reset
### Branches
## Useful links
[Learn git commands in 15 minutes](https://try.github.io)
[Git for beginners](http://readwrite.com/2013/09/30/understanding-github-a-journey-for-beginners-part-1)
[Github desktop client](https://desktop.github.com/)