BigW Consortium Gitlab

basic-git-commands.md 1.31 KB
Newer Older
karen Carias committed
1 2
# Basic Git commands

3
### Go to the master branch to pull the latest changes from there
karen Carias committed
4 5 6 7
```
git checkout master
```

8 9
### Download the latest changes in the project
This is for you to work on an up-to-date copy (it is important to do every time you work on a project), while you setup tracking branches.
karen Carias committed
10 11 12 13 14
```
git pull REMOTE NAME-OF-BRANCH -u
```
(REMOTE: origin) (NAME-OF-BRANCH: could be "master" or an existing branch)

15 16
### Create a branch
Spaces won't be recognized, so you need to use a hyphen or underscore.
karen Carias committed
17 18 19 20
```
git checkout -b NAME-OF-BRANCH
```

21
### Work on a branch that has already been created
karen Carias committed
22 23 24 25
```
git checkout NAME-OF-BRANCH
```

26 27
### View the changes you've made
It's important to be aware of what's happening and what's the status of your changes.
karen Carias committed
28 29 30 31
```
git status
```

32 33
### Add changes to commit
You'll see your changes in red when you type "git status".
karen Carias committed
34 35 36 37 38
```
git add CHANGES IN RED
git commit -m "DESCRIBE THE INTENTION OF THE COMMIT"
```

39
### Send changes to gitlab.com
karen Carias committed
40
```
41
git push REMOTE NAME-OF-BRANCH
karen Carias committed
42 43
```

44
### Delete all changes in the Git repository, but leave unstaged things
karen Carias committed
45 46 47 48
```
git checkout .
```

49
### Delete all changes in the Git repository, including untracked files
karen Carias committed
50 51 52 53
```
git clean -f
```

54 55
### Merge created branch with master branch
You need to be in the created branch.
karen Carias committed
56 57 58 59
```
git checkout NAME-OF-BRANCH
git merge master
```