Skip to content

Commit 9db926e

Browse files
authored
Update gitlab-commands.md
Added basic git commands
1 parent 54c2985 commit 9db926e

1 file changed

Lines changed: 59 additions & 1 deletion

File tree

CI-CD/GitlabCi/gitlab-commands.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,59 @@
1-
# Gitlab Commands
1+
# Gitlab Commands
2+
### Getting & Creating Projects
3+
4+
| Command | Description |
5+
| ------- | ----------- |
6+
| `git init` | Initialize a local Git repository |
7+
| `git clone ssh://git@github.com/[username]/[repository-name].git` | Create a local copy of a remote repository |
8+
9+
### Basic Snapshotting
10+
11+
| Command | Description |
12+
| ------- | ----------- |
13+
| `git status` | Check status |
14+
| `git add [file-name.txt]` | Add a file to the staging area |
15+
| `git add -A` | Add all new and changed files to the staging area |
16+
| `git commit -m "[commit message]"` | Commit changes |
17+
| `git rm -r [file-name.txt]` | Remove a file (or folder) |
18+
19+
### Branching & Merging
20+
21+
| Command | Description |
22+
| ------- | ----------- |
23+
| `git branch` | List branches (the asterisk denotes the current branch) |
24+
| `git branch -a` | List all branches (local and remote) |
25+
| `git branch [branch name]` | Create a new branch |
26+
| `git branch -d [branch name]` | Delete a branch |
27+
| `git push origin --delete [branch name]` | Delete a remote branch |
28+
| `git checkout -b [branch name]` | Create a new branch and switch to it |
29+
| `git checkout -b [branch name] origin/[branch name]` | Clone a remote branch and switch to it |
30+
| `git branch -m [old branch name] [new branch name]` | Rename a local branch |
31+
| `git checkout [branch name]` | Switch to a branch |
32+
| `git checkout -` | Switch to the branch last checked out |
33+
| `git checkout -- [file-name.txt]` | Discard changes to a file |
34+
| `git merge [branch name]` | Merge a branch into the active branch |
35+
| `git merge [source branch] [target branch]` | Merge a branch into a target branch |
36+
| `git stash` | Stash changes in a dirty working directory |
37+
| `git stash clear` | Remove all stashed entries |
38+
39+
### Sharing & Updating Projects
40+
41+
| Command | Description |
42+
| ------- | ----------- |
43+
| `git push origin [branch name]` | Push a branch to your remote repository |
44+
| `git push -u origin [branch name]` | Push changes to remote repository (and remember the branch) |
45+
| `git push` | Push changes to remote repository (remembered branch) |
46+
| `git push origin --delete [branch name]` | Delete a remote branch |
47+
| `git pull` | Update local repository to the newest commit |
48+
| `git pull origin [branch name]` | Pull changes from remote repository |
49+
| `git remote add origin ssh://git@github.com/[username]/[repository-name].git` | Add a remote repository |
50+
| `git remote set-url origin ssh://git@github.com/[username]/[repository-name].git` | Set a repository's origin branch to SSH |
51+
52+
### Inspection & Comparison
53+
54+
| Command | Description |
55+
| ------- | ----------- |
56+
| `git log` | View changes |
57+
| `git log --summary` | View changes (detailed) |
58+
| `git log --oneline` | View changes (briefly) |
59+
| `git diff [source branch] [target branch]` | Preview changes before merging |

0 commit comments

Comments
 (0)