Skip to content

Commit 4ef31b9

Browse files
authored
Create Command.md
0 parents  commit 4ef31b9

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

Command.md

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

0 commit comments

Comments
 (0)