-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit_functions.txt
117 lines (73 loc) · 3.15 KB
/
git_functions.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Guía de funciones y comandos para Git y GitHub
$ git \TAB \TAB
#Shows the options for the current state of command.
$ diff old_file new_file
# Compares differences by line made in new_file vs old_file
$ git log
# Shows all the commits for the files in the repository and their corresponding
# commit id.
$ git log -n X
# Shows the X last commits in the log
$ git log —-stat
# Shows all the commits and deletions + insertions per file
$ git diff commit_id1 commit_id2
# compares changes in commit_id1 and commit_id2
$ git diff
# compares files in working directory and staging area
$ git diff —-staged
# compares files in staging area to last commit on reposotory
$ git —-version
#Shows current version of git
$ git config —-global
#Makes a change that affects ALL of the repositories using git
$ git config —-global color.ui auto
#Changes diff insertions to green and deletions to red
HEAD #commit in which you’re currently on
$ git checkout commit_id
#Takes you to the commit_id version of a repository
$ git status
#Shows which files in the repository have changed since the last commit
#Shows also current branch of the repository and current commit message
$ git add filename
#Tracks the file so the commit includes it
$ git commit
#using Atom as the git config —-global editor, this opens Atom to write and save
#commits of the added files.
$ git -m commit “message”
#Commits “message” into the added files.
$ git log —-graph —-oneline branch1 branch2
#Visualizes branch structure for commits in branch1 and branch2
$ git branch
#Shows current branches (current in green and/or stared)
$ git branch branch_name
# Creates branch called branch_name
$ git checkout -b branch_name == git branch branch_name ; git checkout branch_name
$ git show commit_id
#does git diff of commit_id with its parent
$ git merge branch1 branch2
#merges head commit of branch1 with the one of branch2, also merging the commit
#history timewise. They merge into the current branch.
$ git branch -d branch_name
#deletes branch_name branch (only deletes the label)
$ git stash [list, show, apply, save, clear]
#saves your local modifications away and reverts the working directory to match #the HEAD commit.
$ git reset —hard master~n
#resets current branch to n commits ago on master
### Starting with GitHub (online) commands! ###
$ git remote
#a remote is a repository tracked via an url
$ git clone url
#Copies url’s repository to you directory
$git remote -v
# -v stands for verbose, it shows our remotes with more information, such as the # pushing and fetching urls
$ git remote add origin url
#adds git’s url to a remote called origin (standard)
$ git push remote_name branch_name
#sends committed changes from local branch_name to remote_name at the given url
$ git pull remote_name branch_name
#sends committed changes from url’s remote_name to local branch_name
$ git fork url
#makes a clone of url in the GitHub servers to your account
$ git fetch url
# makes a copy of the current repository at github to your local repository as a different origin/master branch
Obs: git pull == git fetch -> git merge