您可以使用git add 添加文件,例如git add README、git add <folder>/*,甚至git add *
然后使用git commit -m "<Message>" 提交文件
终于git push -u origin master推送文件了。
当您进行修改时,运行 git status,它会为您提供已修改文件的列表,使用 git add * 添加它们,或者您可以单独指定每个文件,然后是 git commit -m <message>,最后是 git push -u origin master
示例 - 假设您创建了一个文件 README,运行 git status 给您
$ git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# README
运行git add README,文件被暂存以进行提交。然后再次运行git status,它应该会给你 - 文件已添加并准备好提交。
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: README
#
nothing added to commit but untracked files present (use "git add" to track)
然后运行git commit -m 'Added README'
$ git commit -m 'Added README'
[master 6402a2e] Added README
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README
最后,git push -u origin master 推送远程分支master 为仓库origin。
$ git push -u origin master
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 267 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To xxx@xxx.com:xxx/xxx.git
292c57a..6402a2e master -> master
Branch master set up to track remote branch master from origin.
文件已成功推送到远程仓库。
运行git pull origin master 以确保您已吸收任何上游更改
$ git pull origin master
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 8 (delta 4), reused 7 (delta 3)
Unpacking objects: 100% (8/8), done.
From xxx.com:xxx/xxx
* branch master -> FETCH_HEAD
Updating e0ef362..6402a2e
Fast-forward
public/javascript/xxx.js | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
create mode 100644 README
如果您不想将上游更改与本地存储库合并,请运行 git fetch 以获取更改,然后运行 git merge 以合并更改。 git pull 只是 fetch 和 merge 的组合。
我个人使用 gitimmersion - http://gitimmersion.com/ 来了解 git 的曲线,这是一个分步指南,如果您需要一些文档和帮助