Skip to content

Commit aa5db05

Browse files
feat:commads added
0 parents  commit aa5db05

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

Git-commands.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
Git Commands
2+
============
3+
4+
_A list of Git commands_
5+
--
6+
feel free to star [this](https://gist.github.com/vimalverma558/6fe59f3b7f886d2210bca28634b3a7fe)
7+
8+
___
9+
___
10+
11+
### Tell Git who you are
12+
13+
| Description | Command |
14+
| ------- | ----------- |
15+
| Configure the author name.|`git config --global user.name "<username>"`|
16+
| Configure the author email address.|`git config --global user.email <email address>`|
17+
18+
19+
20+
### Getting & Creating Projects
21+
22+
| Description | Command |
23+
| ------- | ----------- |
24+
| Initialize a local Git repository | `git init` |
25+
| Create a local copy of a remote repository | `git clone ssh://git@github.com/<username>/<repository-name>.git` |
26+
27+
### Basic Snapshotting
28+
29+
| Description | Command |
30+
| ------- | ----------- |
31+
| Check status | `git status` |
32+
| Add a file to the staging area | `git add <file-name.txt>` |
33+
| Add all new and changed files to the staging area | `git add -A` or <br> `git add .` |
34+
| Commit changes | `git commit -m "<commit message>"` |
35+
| Remove a file (or folder) | `git rm -r <file-name.txt>` |
36+
37+
38+
39+
### Inspection & Comparison
40+
41+
| Description | Command |
42+
| ------- | ----------- |
43+
| View changes | `git log` |
44+
| View changes (detailed) | `git log --summary` |
45+
| View changes in one line (briefly) | `git log --oneline` or <br> `git log --pretty=oneline` or<br> `git log --pretty=short` |
46+
47+
48+
49+
50+
### Undo to previous file
51+
52+
| Description | Command |
53+
| ------- | ----------- |
54+
| List of all commit with commit id and commit message) | `git log --oneline` |
55+
| Return to previous commit <commit id> | `git checkout<commit id>` |
56+
| Revert commit <commit id> (undo one particular commit) | `git revert <commit id>` |
57+
| Reset to previous commit <commit id> (remove history of all commit after <commit id> ) | `git reset --hard <commit id>`|
58+
| Stop a file being tracked | `git rm --cached <file/folder>` |
59+
| Restore a file to a previous commit| `git checkout <file/to/restore>` |
60+
61+
62+
63+
### Branching & Merging
64+
65+
| Description | Command |
66+
| ------- | ----------- |
67+
| List branches (the asterisk denotes the current branch) | `git branch` |
68+
| List all branches (local and remote) | `git branch -a` |
69+
| Create a new branch | `git branch <branch name>` |
70+
| Create a new branch and switch to it | `git checkout -b <branch name>` |
71+
| Clone a remote branch and switch to it | `git checkout -b <branch name> origin/<branch name>` |
72+
| Rename a local branch | `git branch -m <old branch name> <new branch name>` |
73+
| Switch to a branch | `git checkout <branch name>` |
74+
| Switch to the branch last checked out | `git checkout -` |
75+
| Discard changes to a file | `git checkout -- <file-name.txt>` |
76+
| Delete a branch | `git branch -d <branch name>` |
77+
| Delete a remote branch | `git push origin --delete <branch name>` |
78+
| Preview changes before merging | `git diff <source branch> <target branch>` |
79+
| Merge a branch into the active branch | `git merge <branch name>` |
80+
| Merge a branch into a target branch | `git merge <source branch> <target branch>` |
81+
| Stash changes in a dirty working directory | `git stash` |
82+
| Remove all stashed entries | `git stash clear` |
83+
84+
### Sharing & Updating Projects
85+
86+
| Description | Command |
87+
| ------- | ----------- |
88+
| Push a branch to your remote repository | `git push origin <branch name>` |
89+
| Push changes to remote repository (and remember the branch) | `git push -u origin <branch name>` |
90+
| Push changes to remote repository (remembered branch) | `git push` |
91+
| Push changes to remote repository all branch | `git push --all` |
92+
| Push changes to remote repository (Force) | `git push -f` |
93+
| Delete a remote branch | `git push origin --delete <branch name>` |
94+
| Update local repository to the newest commit | `git pull` |
95+
| Pull changes from remote repository | `git pull origin <branch name>` |
96+
| Add a remote repository | `git remote add origin ssh://git@github.com/<username>/<repository-name>.git` |
97+
| Set a repository's origin branch to SSH | `git remote set-url origin ssh://git@github.com/<username>/<repository-name>.git` |
98+
99+
100+
[follow](https://github.com/vimalverma558)

0 commit comments

Comments
 (0)