-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand_git.txt
55 lines (36 loc) · 2.81 KB
/
command_git.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
Default Git command from DZONE Link ===> https://dzone.com/articles/open-source-databases-pros-and-cons-of-3-popular-d
The [] show the type of content to add
git init [repository name] // Start a new repository.
git clone [url] // Obtain a repository from an existing URL.
git add [file] // Adds a file to the staging area.
git add * // Adds one or more file to the staging area.
git commit -m “[ Type in the commit message]” // Records or snapshots the file permanently in the version history.
git commit -a // Commits any files you’ve added with the git add command and also commits any files you’ve changed since then.
git diff // Shows the file differences which are not yet staged.
git diff --staged // Shows the differences between the files in the staging area and the latest version present.
git diff [first branch] [second branch] // Shows the differences between the two branches mentioned.
git reset [file] // Unstages the file, but it preserves the file contents.
git reset [commit] // Undoes all the commits after the specified commit and preserves the changes locally.
git reset --hard [commit] // Discards all history and goes back to the specified commit.
git status // Lists all the files that have to be committed.
git rm [file] // Deletes the file from your working directory and stages the deletion.
git log // List the version history for the current branch.
git log --follow [file] // Lists version history for a file, including the renaming of files also.
git show [commit] // Shows the metadata and content changes of the specified commit.
git tag [commitID] // Give tags to the specified commit.
git branch // Lists all the local branches in the current repository.
git branch [branch name] // Creates a new branch.
git branch -d [branch name] // Deletes the feature branch.
git checkout [branch name] // Switch from one branch to another.
git checkout -b [branch name] // Creates a new branch and also switches to it.
git merge [branch name] // Merges the specified branch’s history into the current branch.
git remote add [variable name] [Remote Server Link] // Connect your local repository to the remote server.
git push [variable name] master // Sends the committed changes of master branch to your remote repository.
git push [variable name] [branch] // Sends the branch commits to your remote repository.
git push –all [variable name] // Pushes all branches to your remote repository.
git push [variable name] :[branch name] // Deletes a branch on your remote repository.
git pull [Repository Link] // Fetches and merges changes on the remote server to your working directory.
git stash save // Temporarily stores all the modified tracked files.
git stash pop // Restores the most recently stashed files.
git stash list // Lists all stashed changesets.
git stash drop // Discards the most recently stashed changeset.