最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[已解决]git 命令行方式去上传代码到远程到git服务器

Git crifan 2974浏览 0评论

[背景]

需要去用git命令行的方式去把项目代码上传到git服务器。

[折腾过程]

1.搜:

git 命令行
 参考:
然后去试试:
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
Last login: Thu Oct 22 10:10:28 on ttys000
licrifandeMacBook-Pro:iOS-Client crifan$ pwd
/Users/crifan/dev/dev_root/daryun/JianDao/iOS-Client
licrifandeMacBook-Pro:iOS-Client crifan$ git
git git-receive-pack git-upload-archive
git-cvsserver git-shell git-upload-pack
licrifandeMacBook-Pro:iOS-Client crifan$ git log
commit b43b035b407bd95d0487f2e6e4229cb8c509176b
Author: xxxxxxx <xxxxxxxxxx@xxxx.com>
Date: Sat Oct 24 17:28:23 2015 +0800
 
 Initial commit
licrifandeMacBook-Pro:iOS-Client crifan$ git show
commit b43b035b407bd95d0487f2e6e4229cb8c509176b
Author: xxxxxxx <xxxxxxxxxx@xxxx.com>
Date: Sat Oct 24 17:28:23 2015 +0800
 
 Initial commit
 
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4c72a5b
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+#iOS-Client^M
licrifandeMacBook-Pro:iOS-Client crifan$ cd
.DS_Store .git/ JianDao/ README.md
licrifandeMacBook-Pro:iOS-Client crifan$ cd JianDao/
licrifandeMacBook-Pro:JianDao crifan$ ls -l
total 208
-rw-r--r--@ 1 crifan staff 297 10 24 15:56 ContactViewController.swift
-rw-r--r--@ 1 crifan staff 292 10 24 15:57 FileViewController.swift
drwxr-xr-x 9 crifan staff 306 10 27 13:05 JianDao
drwxr-xr-x 5 crifan staff 170 10 27 11:43 JianDao.xcodeproj
drwxr-xr-x 4 crifan staff 136 10 27 11:40 JianDaoTests
drwxr-xr-x 4 crifan staff 136 10 27 11:40 JianDaoUITests
-rw-r--r--@ 1 crifan staff 4593 10 26 17:48 MainViewController.swift
-rw-r--r--@ 1 crifan staff 6974 10 27 09:28 MessageViewController.swift
-rw-r--r--@ 1 crifan staff 312 10 24 15:57 PersonalCenterViewController.swift
-rw-r--r--@ 1 crifan staff 4674 10 24 14:27 SwiftColors.swift
-rw-r--r--@ 1 crifan staff 837 10 24 15:33 add_white_24x24.png
-rw-r--r-- 1 crifan staff 1630 10 24 16:42 contact_selected.png
-rw-r--r-- 1 crifan staff 2041 10 24 16:43 contact_unselected.png
-rw-r--r-- 1 crifan staff 801 10 24 16:43 file_selected.png
-rw-r--r-- 1 crifan staff 2424 10 24 16:43 file_unselected.png
-rw-r--r--@ 1 crifan staff 2196 10 26 14:05 hdImg_haolenghou_48x48.jpg
-rw-r--r-- 1 crifan staff 2060 10 26 14:02 hdImg_limao_48x48.jpg
-rw-r--r-- 1 crifan staff 2025 10 26 14:03 hdImg_pnp_48x48.jpg
-rw-r--r--@ 1 crifan staff 1999 10 26 14:01 hdImg_wutao_48x48.jpg
-rw-r--r-- 1 crifan staff 1966 10 26 14:02 hdImg_xuchen_48x48.jpg
-rw-r--r-- 1 crifan staff 2041 10 26 14:03 hdImg_zhangbinglian_48x48.jpg
-rw-r--r-- 1 crifan staff 1435 10 24 16:44 message_selected.png
-rw-r--r-- 1 crifan staff 1308 10 24 16:44 message_unselected.png
-rw-r--r-- 1 crifan staff 1328 10 24 16:44 personal_center_selected.png
-rw-r--r-- 1 crifan staff 1190 10 24 16:44 personal_center_unselected.png
-rw-r--r--@ 1 crifan staff 524 10 26 15:58 prevent_disturb_16x24.png
-rw-r--r--@ 1 crifan staff 1407 10 24 15:36 search_24x24.png
licrifandeMacBook-Pro:JianDao crifan$ git config
usage: git config [<options>]
 
Config file location
 --global use global config file
 --system use system config file
 --local use repository config file
 -f, --file <file> use given config file
 --blob <blob-id> read config from given blob object
 
Action
 --get get value: name [value-regex]
 --get-all get all values: key [value-regex]
 --get-regexp get values for regexp: name-regex [value-regex]
 --get-urlmatch get value specific for the URL: section[.var] URL
 --replace-all replace all matching variables: name value [value_regex]
 --add add a new variable: name value
 --unset remove a variable: name [value-regex]
 --unset-all remove all matches: name [value-regex]
 --rename-section rename section: old-name new-name
 --remove-section remove a section: name
 -l, --list list all
 -e, --edit open an editor
 --get-color find the color configured: slot [default]
 --get-colorbool find the color setting: slot [stdout-is-tty]
 
Type
 --bool value is "true" or "false"
 --int value is decimal number
 --bool-or-int value is --bool or --int
 --path value is a path (file or directory name)
 
Other
 -z, --null terminate values with NUL byte
 --includes respect include directives on lookup
 
licrifandeMacBook-Pro:JianDao crifan$ git config --list
core.bare=false
core.repositoryformatversion=0
core.filemode=true
core.ignorecase=true
core.precomposeunicode=true
core.logallrefupdates=true
remote.origin.url=https://git.oschina.net/xxxxxxx/iOS-Client.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
licrifandeMacBook-Pro:JianDao crifan$ git config --global user.name
licrifandeMacBook-Pro:JianDao crifan$ git config --global user.name crifan
licrifandeMacBook-Pro:JianDao crifan$ git config --global user.name
crifan
licrifandeMacBook-Pro:JianDao crifan$ cd ..
licrifandeMacBook-Pro:iOS-Client crifan$ git config --global user.name
crifan
licrifandeMacBook-Pro:iOS-Client crifan$ ls -la
total 24
drwxr-xr-x 6 crifan staff 204 10 27 11:40 .
drwxr-xr-x 4 crifan staff 136 10 27 11:39 ..
-rw-r--r--@ 1 crifan staff 6148 10 27 13:48 .DS_Store
drwxr-xr-x 11 crifan staff 374 10 27 11:44 .git
drwxr-xr-x 30 crifan staff 1020 10 27 13:05 JianDao
-rw-r--r-- 1 crifan staff 13 10 27 11:39 README.md
licrifandeMacBook-Pro:iOS-Client crifan$ ls -l
total 8
drwxr-xr-x 30 crifan staff 1020 10 27 13:05 JianDao
-rw-r--r-- 1 crifan staff 13 10 27 11:39 README.md
licrifandeMacBook-Pro:iOS-Client crifan$ git -add --help
Unknown option: -add
usage: git [--version] [--help] [-C <path>] [-c name=value]
 [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
 [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
 [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
 <command> [<args>]
licrifandeMacBook-Pro:iOS-Client crifan$ git add --help
licrifandeMacBook-Pro:iOS-Client crifan$ git add --help
licrifandeMacBook-Pro:iOS-Client crifan$ git add .
licrifandeMacBook-Pro:iOS-Client crifan$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
 (use "git reset HEAD <file>..." to unstage)
 
new file: .DS_Store
new file: JianDao/.DS_Store
new file: JianDao/ContactViewController.swift
new file: JianDao/FileViewController.swift
new file: JianDao/JianDao.xcodeproj/project.pbxproj
new file: JianDao/JianDao.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file: JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate
new file: JianDao/JianDao.xcodeproj/xcuserdata/crifan.xcuserdatad/xcschemes/JianDao.xcscheme
new file: JianDao/JianDao.xcodeproj/xcuserdata/crifan.xcuserdatad/xcschemes/xcschememanagement.plist
new file: JianDao/JianDao/.DS_Store
new file: JianDao/JianDao/AppDelegate.swift
new file: JianDao/JianDao/Assets.xcassets/AppIcon.appiconset/Contents.json
new file: JianDao/JianDao/Base.lproj/LaunchScreen.storyboard
new file: JianDao/JianDao/Base.lproj/Main.storyboard
new file: JianDao/JianDao/Constants.swift
new file: JianDao/JianDao/Info.plist
new file: JianDao/JianDao/JianDao.xcdatamodeld/.xccurrentversion
new file: JianDao/JianDao/JianDao.xcdatamodeld/JianDao.xcdatamodel/contents
new file: JianDao/JianDaoTests/Info.plist
new file: JianDao/JianDaoTests/JianDaoTests.swift
new file: JianDao/JianDaoUITests/Info.plist
new file: JianDao/JianDaoUITests/JianDaoUITests.swift
new file: JianDao/MainViewController.swift
new file: JianDao/MessageViewController.swift
new file: JianDao/PersonalCenterViewController.swift
new file: JianDao/SwiftColors.swift
new file: JianDao/add_white_24x24.png
new file: JianDao/contact_selected.png
new file: JianDao/contact_unselected.png
new file: JianDao/file_selected.png
new file: JianDao/file_unselected.png
new file: JianDao/hdImg_haolenghou_48x48.jpg
new file: JianDao/hdImg_limao_48x48.jpg
new file: JianDao/hdImg_pnp_48x48.jpg
new file: JianDao/hdImg_wutao_48x48.jpg
new file: JianDao/hdImg_xuchen_48x48.jpg
new file: JianDao/hdImg_zhangbinglian_48x48.jpg
new file: JianDao/message_selected.png
new file: JianDao/message_unselected.png
new file: JianDao/personal_center_selected.png
new file: JianDao/personal_center_unselected.png
new file: JianDao/prevent_disturb_16x24.png
new file: JianDao/search_24x24.png
 
licrifandeMacBook-Pro:iOS-Client crifan$ git commit -m "crifan first commit, can show basic message list"
[master a82c39d] crifan first commit, can show basic message list
 Committer: crifan <crifan@licrifandeMacBook-Pro.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
 
 git config --global user.name "Your Name"
 git config --global user.email you@example.com
 
After doing this, you may fix the identity used for this commit with:
 
 git commit --amend --reset-author
 
 43 files changed, 1670 insertions(+)
 create mode 100644 .DS_Store
 create mode 100644 JianDao/.DS_Store
 create mode 100644 JianDao/ContactViewController.swift
 create mode 100644 JianDao/FileViewController.swift
 create mode 100644 JianDao/JianDao.xcodeproj/project.pbxproj
 create mode 100644 JianDao/JianDao.xcodeproj/project.xcworkspace/contents.xcworkspacedata
 create mode 100644 JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate
 create mode 100644 JianDao/JianDao.xcodeproj/xcuserdata/crifan.xcuserdatad/xcschemes/JianDao.xcscheme
 create mode 100644 JianDao/JianDao.xcodeproj/xcuserdata/crifan.xcuserdatad/xcschemes/xcschememanagement.plist
 create mode 100644 JianDao/JianDao/.DS_Store
 create mode 100644 JianDao/JianDao/AppDelegate.swift
 create mode 100644 JianDao/JianDao/Assets.xcassets/AppIcon.appiconset/Contents.json
 create mode 100644 JianDao/JianDao/Base.lproj/LaunchScreen.storyboard
 create mode 100644 JianDao/JianDao/Base.lproj/Main.storyboard
 create mode 100644 JianDao/JianDao/Constants.swift
 create mode 100644 JianDao/JianDao/Info.plist
 create mode 100644 JianDao/JianDao/JianDao.xcdatamodeld/.xccurrentversion
 create mode 100644 JianDao/JianDao/JianDao.xcdatamodeld/JianDao.xcdatamodel/contents
 create mode 100644 JianDao/JianDaoTests/Info.plist
 create mode 100644 JianDao/JianDaoTests/JianDaoTests.swift
 create mode 100644 JianDao/JianDaoUITests/Info.plist
 create mode 100644 JianDao/JianDaoUITests/JianDaoUITests.swift
 create mode 100644 JianDao/MainViewController.swift
 create mode 100644 JianDao/MessageViewController.swift
 create mode 100644 JianDao/PersonalCenterViewController.swift
 create mode 100644 JianDao/SwiftColors.swift
 create mode 100644 JianDao/add_white_24x24.png
 create mode 100644 JianDao/contact_selected.png
 create mode 100644 JianDao/contact_unselected.png
 create mode 100644 JianDao/file_selected.png
 create mode 100644 JianDao/file_unselected.png
 create mode 100644 JianDao/hdImg_haolenghou_48x48.jpg
 create mode 100644 JianDao/hdImg_limao_48x48.jpg
 create mode 100644 JianDao/hdImg_pnp_48x48.jpg
 create mode 100644 JianDao/hdImg_wutao_48x48.jpg
 create mode 100644 JianDao/hdImg_xuchen_48x48.jpg
 create mode 100644 JianDao/hdImg_zhangbinglian_48x48.jpg
 create mode 100644 JianDao/message_selected.png
 create mode 100644 JianDao/message_unselected.png
 create mode 100644 JianDao/personal_center_selected.png
 create mode 100644 JianDao/personal_center_unselected.png
 create mode 100644 JianDao/prevent_disturb_16x24.png
 create mode 100644 JianDao/search_24x24.png
licrifandeMacBook-Pro:iOS-Client crifan$ git log
commit a82c39d190fc47a11c97b47d6f701740694830e6
Author: crifan <crifan@licrifandeMacBook-Pro.local>
Date: Tue Oct 27 13:52:06 2015 +0800
 
 crifan first commit, can show basic message list
 
commit b43b035b407bd95d0487f2e6e4229cb8c509176b
Author: xxxxxxx <xxxxxxxxxx@xxxx.com>
Date: Sat Oct 24 17:28:23 2015 +0800
 
 Initial commit
licrifandeMacBook-Pro:iOS-Client crifan$ git config --global user.email
licrifandeMacBook-Pro:iOS-Client crifan$ git config --global user.email "yyy@yyy.com"
licrifandeMacBook-Pro:iOS-Client crifan$ git config --global user.email
yyy@yyy.com
licrifandeMacBook-Pro:iOS-Client crifan$ git commit --amend --reset-author
 
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (use "git push" to publish your local commits)
#
# Changes to be committed:
# new file: .DS_Store
# new file: JianDao/.DS_Store
# new file: JianDao/ContactViewController.swift
# new file: JianDao/FileViewController.swift
# new file: JianDao/JianDao.xcodeproj/project.pbxproj
# new file: JianDao/JianDao.xcodeproj/project.xcworkspace/contents.xcworkspacedata
# new file: JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/UserInterfaceState.xcuserstate
# new file: JianDao/JianDao.xcodeproj/xcuserdata/crifan.xcuserdatad/xcschemes/JianDao.xcscheme
# new file: JianDao/JianDao.xcodeproj/xcuserdata/crifan.xcuserdatad/xcschemes/xcschememanagement.plist
# new file: JianDao/JianDao/.DS_Store
# new file: JianDao/JianDao/AppDelegate.swift
# new file: JianDao/JianDao/Assets.xcassets/AppIcon.appiconset/Contents.json
# new file: JianDao/JianDao/Base.lproj/LaunchScreen.storyboard
# new file: JianDao/JianDao/Base.lproj/Main.storyboard
# new file: JianDao/JianDao/Constants.swift
# new file: JianDao/JianDao/Info.plist
# new file: JianDao/JianDao/JianDao.xcdatamodeld/.xccurrentversion
# new file: JianDao/JianDao/JianDao.xcdatamodeld/JianDao.xcdatamodel/contents
# new file: JianDao/JianDaoTests/Info.plist
# new file: JianDao/JianDaoTests/JianDaoTests.swift
# new file: JianDao/JianDaoUITests/Info.plist
# new file: JianDao/JianDaoUITests/JianDaoUITests.swift
# new file: JianDao/MainViewController.swift
# new file: JianDao/MessageViewController.swift
# new file: JianDao/PersonalCenterViewController.swift
# new file: JianDao/SwiftColors.swift
# new file: JianDao/add_white_24x24.png
# new file: JianDao/contact_selected.png
# new file: JianDao/contact_unselected.png
# new file: JianDao/file_selected.png
# new file: JianDao/file_unselected.png
结果:
最后还是没有commit完成:
type quit enter no response
enter后,都无法结束。。。
再继续重新试试:
want to use your keychain oschina
然后继续操作:
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
licrifandeMacBook-Pro:iOS-Client crifan$ git push origin master
Counting objects: 60, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (54/54), done.
Writing objects: 100% (60/60), 53.50 KiB | 0 bytes/s, done.
Total 60 (delta 5), reused 0 (delta 0)
To https://git.oschina.net/windoze/iOS-Client.git
   b43b035..a82c39d  master -> master
licrifandeMacBook-Pro:iOS-Client crifan$ git log
commit a82c39d190fc47a11c97b47d6f701740694830e6
Author: crifan <crifan@licrifandeMacBook-Pro.local>
Date:   Tue Oct 27 13:52:06 2015 +0800
 
    crifan first commit, can show basic message list
 
commit b43b035b407bd95d0487f2e6e4229cb8c509176b
Author: Windoze <windoze.net@gmail.com>
Date:   Sat Oct 24 17:28:23 2015 +0800
 
    Initial commit
licrifandeMacBook-Pro:iOS-Client crifan$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
licrifandeMacBook-Pro:iOS-Client crifan$
但是很明显:
没有把文件加进来,没有上传成功。
然后后来去网站上看,实际上的确已经上传了:
oschina show commited code
ios client jiandao show all code
[总结]
上传之前,最好设置好自己的用户名和邮箱:
1
2
git config --global user.name crifan
git config --global user.email “xxx@xxx.com"
其中:
1
2
git config --global user.name
git config --global user.email
可以查看当前的用户名和邮箱
然后再去上传代码:
1
2
3
git add .
git commit -m "input your comments here"
git push origin master
传完之后可以去看看状态和log:
1
2
git log
git status

转载请注明:在路上 » [已解决]git 命令行方式去上传代码到远程到git服务器

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
85 queries in 0.201 seconds, using 22.23MB memory