-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_commnds.txt
More file actions
133 lines (120 loc) · 4.27 KB
/
git_commnds.txt
File metadata and controls
133 lines (120 loc) · 4.27 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
===========LOCAL==================================================
git config
: to say who are you
----------------------
git init
: make a forest in current location (add repository to this folder)
--------------------
git status
: see status
--------------------
git log
: see history
----------
git add [--all]
: mark changed and new files to be added to local server in next commit
: mark as edited/new
------------------
git commit -m "Comment here"
: submit the files to local server
wq
: sace and quit vim
--------------------
git commit -a
: commit all files in project even not added (= add --all + commit)
--------------------------
git push
: submit the files from local server to remote server
------------------------
git reset
: return state of all added files (revert "git add" action)
------------------------
git reset --hard
: return the files to last commited content (revert)
-----------------------------------
============== DIFF ================================================
git diff [{FileName}]
: compare localFile with stageing file(if there's no stage => local repo)
---------------------------------
git diff --staged [{FileName}]
: compare sgating file with local repo
---------------------------------
git diff HEAD [{FileName}]
: compare local file with local repo
-------------------------------------
gitk
: open GUI with history of commits
----------------------------------------
git log --oneline --all --graph --decorate
: get a graph with branches and commits in console
==========LOCAL BACKUP===============================================
git init --bare
: create a backup repository in dir
-----------------------------------
===========REMOTE====================================================
git remote [-v]
: view remote locations and paths to them
------------------------------------------
git remote add {SomeRemoteName} {PathToRepo}
: add remote location to can push later
--------------------------------
git push {SomeRemoteName} [{branch}]
: commit to remote server
----------------------------------
git init --bare --shared
:
------------------------------------
git fetch {SomeRemoteName}
: update from remote server (get changes)
-------------------------------
git rebase {SomeRemoteName}
: applies changes from fetch to local copy
---------------------------------
-----------------------------------------
git fetch {SomeRemoteName}
: get from remote server changes (staged)
-----------------------------------------
git pull {SomeRemoteName}
: fetch + merge = get from remote server changes and add it to (local files)
------------------------------------------
git pull -u {SomeRemoteName}
:
------------------------------------------
============BRANCHES=====================================
git branch [-a]
: return the name of all branches
----------------------------------
git branch {nameOfBranch}
: create branch
----------------------------------
git checkout {BranchName}
: switch the local repo to points to other brantch
----------------------------------
git branch -d {branchName}
: delete branch (delete only pointers to branch, history stays)
-----------------------------------
git rebase {BranchName}
: add commits from the {BranchName} to current branch to the position in time when they are realy commited.
: 1) return the current brantch to state just before make the other brantch.
: 2) commit all {branchName} commits
: 3) commit all current branch commits
: ? mixed commits?
: ? update inner brantch with changes from main?
===========MERGE==========================================
git merge {branchName}
: merge selected branch to(with) current brantch
----------------------------------------------------------
=========== SSH =============================================
....
http://net.tutsplus.com/tutorials/tools-and-tips/ssh-what-and-how/
.....
==============================================================
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:peterdenev/testMasterRemote.git
git push -u origin master
Push an existing repository from the command line
git remote add origin git@github.com:peterdenev/testMasterRemote.git
git push -u origin master