forked from infotainment/linuxpedia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_guide
More file actions
131 lines (81 loc) · 4.03 KB
/
Copy pathgit_guide
File metadata and controls
131 lines (81 loc) · 4.03 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
mkdir ~/Hello-World
# Creates a directory for your project called "Hello-World" in your user directory
cd ~/Hello-World
# Changes the current working directory to your newly created directory
git init
# Sets up the necessary Git files
# Initialized empty Git repository in /Users/you/Hello-World/.git/
touch README
# Creates a file called "README" in your Hello-World directory
git add README
# Stages your README file, adding it to the list of files to be committed
git commit -m 'first commit'
# Commits your files, adding the message "first commit"
git remote add origin https://github.com/username/Hello-World.git
# Creates a remote named "origin" pointing at your GitHub repo
git push origin master
# Sends your commits in the "master" branch to GitHub
************************************************************************************************
git clone https://github.com/username/Spoon-Knife.git
# Clones your fork of the repo into the current directory in terminal
************************************************************************************************
cd Spoon-Knife
# Changes the active directory in the prompt to the newly cloned "Spoon-Knife" directory
git remote add upstream https://github.com/octocat/Spoon-Knife.git
# Assigns the original repo to a remote called "upstream"
git fetch upstream
# Pulls in changes not present in your local repository, without modifying your files
************************************************************************************************
git push origin master
# Pushes commits to your remote repo stored on GitHub
************************************************************************************************
git fetch upstream
# Fetches any new changes from the original repo
git merge upstream/master
# Merges any changes fetched into your working files
************************************************************************************************
alternative
git pull upstream
# Pulls commits from 'upstream' and stores them in the local repo
************************************************************************************************
git branch mybranch
# Creates a new branch called "mybranch"
git checkout mybranch
# Makes "mybranch" the active branch
****************************
git checkout -b mybranch
# Creates a new branch called "mybranch" and makes it the active branch
***********************************
git checkout master
# Makes "master" the active branch
git checkout mybranch
# Makes "mybranch" the active branch
************************************************
git checkout master
# Makes "master" the active branch
git merge mybranch
# Merges the commits from "mybranch" into "master"
git branch -d mybranch
# Deletes the "mybranch" branch
************************************************************************************************
************************************************************************************************
************************************************************************************************
http://effectif.com/git/recovering-lost-git-commits
Recovering from reset
git reflog
... snip ...
cf42fa2... HEAD@{84}: checkout: moving to master
73b9363... HEAD@{85}: commit: Don't symlink to themes on deployment.
547cc1b... HEAD@{86}: commit: Deploy to effectif.com web server.
1dc3298... HEAD@{87}: commit: Updated the theme.
18c3f51... HEAD@{88}: commit: Verify with Google webmaster tools.
26fbb9c... HEAD@{89}: checkout: moving to effectif
git checkout effectif
git reset --hard 73b9363
************************************************************************************************
************************************************************************************************
************************************************************************************************
manual deletion of all git binaries from system
sudo find /usr/local -depth -iname 'git*' -exec rm -rf {} \;
//not able clone using "https:git" repos "FIXME"
************************************************************************************************