-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgitNotes.txt
93 lines (53 loc) · 2.97 KB
/
gitNotes.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
for windows - fc
for checking the difference between two files.
for linux/mac - diff
these commands show the differences between two files thereby helping to locate the bug.
also,
~/.bashrc (it acts like environment variable in windows.)
GIT COMMANDS(notes)
>git log (it shows commit history)
>git diff <older version commit id> <newer version commit id> (similar to fc)
>git log --stat (it gives stats along with the logs)
>git config --global color.ui auto (to get diff colorfull. --global makes it global)
>git checkout <commit id> (this is to get to the state of the files during that commit)
>git config --global core.editor
push.default upstream
merge.conflictstyle diff3
>git init (this initializes a directory as a git repository and make a .git folder which contains the meta data.)
>git diff (this command shows the difference between the working dir and the staging area)
>git diff --staged (this command shows the difference between the staging area and the repository)
>git reset --hard (it resets the changes to the last commit made.)
>git branch (shows all the branches that are present in a repo.)
>git branch <name of new branch> (to create a new branch with the give name.)
>git checkout <branch-name> (to checkout to the branch name "branch-name")
>git log --graph (this gives graphical log.)
>git log --graph --oneline (shorter version)
>git checkout -b <bn> (creates a new branch and checkout it)
>git merge master coin (merges the coin branch to master branch)
>git show <commit id> (it shows the difference between a commit and its parent)
>git branch -d <bn> (delete the branch bn - only the label is deleted. commits are preseved if reachable)
To merge-
checkout the branch you want to merge into.
then,
>git merge <bn> (bn - the branch to be merged into the current branch)
if conflict,
open the files with conflict, resolve,
then,
add the files to the stagin area, and then commit to successfully merge.
>git log -n 1 (-n = number of logs to return)
>git remote (shows remotes that are added - repositories on git server like gitHub or bitBucket)
>git remote add <name> <url> (to sync the local repo to a remote repo)
>git push origin master (origin - remote name, master - local repo's branch to be pushed)
To set an upstream,
>git push --set-upstream origin master (sets an upstream from master to origin, after this git push will automatically push from master to origin with "git push".)
if a stream is set from local to remote,
>git pull (directly pulls and sync remote and local)
else,
>git pull origin master (origin - remote, master - local branch name)
>git fetch (this fetches data from remote and adds to the local, in case of conflict - this points to origin/master whereas the local points
to master)
In case of conflict, solve the conflict after git fetch, commit the change and push it.
Pull requests-
These can be made from gitHub.
###### adding another command to understand commits.
##### commiting from the remote repo