如何利用终端命令将文件上传到github远程服务器
(1) git status 命令查看下状态。
(2) git pull 更新代码,确保代码是库上最新代码,防止覆盖其他人的提交。
(3) git add xxx/xxx 把修改后的文件加入到缓冲区。
(4) git commit 提交入库到本地服务器中,这一步会加入注释。
(5) git log 命令查看已提交的修改,是否正确。
(6) git push 命令把本地服务器上的内容更新到远程服务器上。
Test
、## |--> SpongeBob:Extended Belief$ 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: Log/NSArray+Log.h
new file: Log/NSArray+Log.m
更新代码
、## |--> SpongeBob:Extended Belief$ git pull
Already up-to-date.
SpongeBob:Extended Belief$ git add arch/arm/mach-msm/Log/NSArray+Log.h
fatal: pathspec 'arch/arm/mach-msm/Log/NSArray+Log.h' did not match any files
将文件添加到缓冲区
、## |--> SpongeBob:Extended Belief$ git add Log/NSArray+Log.h Log/NSArray+Log.m
提交到本地服务器
、## |--> SpongeBob:Extended Belief$ git commit
[master 32d9e8c] 1.0 增加Log类扩展--中文,显示json解析后的数据。
2 files changed, 44 insertions(+)
create mode 100644 Log/NSArray+Log.h
create mode 100644 Log/NSArray+Log.m
、## |--> SpongeBob:Extended Belief$ git log
commit 32d9e8c8219808493b708365b5d584464e9d4456
Author: SpongeBob_Han <1605319671@qq.com>
Date: Tue May 19 01:04:56 2015 +0800
1.0 增加Log类扩展--中文,显示json解析后的数据。
commit b70ed276b4bc1ec67d443dc47c0c48ffbabae7ec
Author: Bing Ma <1605319671@qq.com>
Date: Tue May 19 00:45:19 2015 +0800
Initial commit
提交到远程服务器
、## |--> SpongeBob:Extended Belief$ git push
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 839 bytes | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To https://github.com/SpongeBob-GitHub/Extended.git
b70ed27..32d9e8c master -> master
SpongeBob:Extended Belief$
GitHub下载:https://github.com/SpongeBob-GitHub/Extended