-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathgitcmds.txt
90 lines (40 loc) · 3.4 KB
/
gitcmds.txt
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
87
88
89
$ git init <directory> -> Create empty Git repo in specified directory.
$ git init -> Run with no arguments to initialize the current directory as a git repository.
$ git clone <repo> -> Clone repo located at <repo> onto local machine.
e.g: $ git clone https://github.com/lekhansh109/Practice-Project.git
$ git config user.name <name> -> Define author name to be used for all commits in current repo.
$ git config --global user.name <name> -> --global flag is used to set config options for current user.
$ git config user.email <email> -> Configure user email for the current repo.
$ git branch -a -> List all of the branches in your repo.
$ git branch <branch> -> create a new branch with the name <branch>.
$ git checkout <branch> -> to checkout an existing branch named branch.
$ git checkout -b <branch> -> Create and check out a new branch named <branch>.
$ git merge <branch> -> Merge <branch> into the current branch.
$ git status -> List which files are staged, unstaged, and untracked.
$ git add . -> Stage all the changes for the next commit.
$ git add <file> -> Stage the changes in a specific file.
$ git commit -m "message" -> Commit the staged snapshot with <message> as the commit message.
$ git commit -a -m <message> -> stage all the changes and commit the staged snapshot with <message> as the commit message.
$ git commit -m <message> -S -> Commit with <message> as the commit message and add signature.
$ git log -> Display the entire commit history using the default format.
$ git log -<limit> -> Limit number of commits by <limit>.
e.g. ”git log -5” will limit to 5 commits.
$ git log -p -> Display the full diff of each commit.
$ git reset <file> -> Remove <file> from the staging area, but leave the working directory unchanged. This unstages a file without overwriting any changes.
$ git revert <commit> -> Create new commit that undoes all of the changes made in <commit>, then apply it to the current branch.
$ git stash -> Saves uncommitted changes (both staged + unstaged) for later use, and reverts them from your working copy
$ git stash pop -> Removes your stash changes and reapplies them to your working copy
$ git stash apply -> Keeps your stash changes for reuse and reapplies them to your working copy
$ git stash list -> List the stash entries that you currently have
$ git stash clear -> Remove all the stash entries
$ git diff -> diff of what is changed but not staged.
$ git diff --staged -> diff of what is staged but not yet committed.
$ git diff --cached -> Show difference between staged changes and last commit.
$ git pull -> fetch and merge any commits from the tracking remote branch.
$ git push -> Transmit local branch commits to the remote repository branch.
$ git checkout <remotebranch> ->check out the remote branch like a local branch.
$ git clean -> Removes untracked files from the working directory.
$ git config --global credential.helper store -> Prevent ask username and password
$ git remote -v -> View remote repository configuration
$ git tag [commitID] -> This command is used to give tags to the specified commit.
$ git config --global alias.commend 'commit --amend --no-edit' -> git commend quietly tacks any staged files onto the last commit you created, re-using your existing commit message.