Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I created an account on GitHub — I'm new on it — and I'm facing a problem with adding files.

(我在GitHub上创建了一个帐户 - 我是新手 - 我正面临添加文件的问题。)

I have added readme.txt .

(我添加了readme.txt 。)

Also, I have 3 other PHP files and a folder including images.

(另外,我有3个其他PHP文件和一个包含图像的文件夹。)

How do I add the files and folder?

(如何添加文件和文件夹?)

I tried it with git pull because git push origin -u master showed me an error.

(我用git pull尝试了它,因为git push origin -u master向我显示了一个错误。)

  ask by Adnan translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
370 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can add files using git add , example git add README , git add <folder>/* , or even git add *

(您可以使用git add添加文件,例如git add READMEgit add <folder>/* ,甚至git add *)

Then use git commit -m "<Message>" to commit files

(然后使用git commit -m "<Message>"提交文件)

Finally git push -u origin master to push files.

(最后git push -u origin master来推送文件。)

When you make modifications run git status which gives you the list of files modified, add them using git add * for everything or you can specify each file individually, then git commit -m <message> and finally, git push -u origin master

(当您进行修改时,运行git status ,它会为您提供修改的文件列表,使用git add *为所有内容添加它们,或者您可以单独指定每个文件,然后git commit -m <message>最后, git push -u origin master)

Example - say you created a file README, running git status gives you

(示例 - 假设您创建了一个README文件,运行git status会给您)

$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   README

Run git add README , the files are staged for committing.

(运行git add README ,将文件暂存以进行提交。)

Then run git status again, it should give you - the files have been added and ready for committing.

(然后再次运行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)

Then run git commit -m 'Added README'

(然后运行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

Finally, git push -u origin master to push the remote branch master for the repository origin .

(最后, git push -u origin master推送存储库origin的远程分支master服务器。)

$ 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.

The files have been pushed successfully to the remote repository.

(文件已成功推送到远程存储库。)

Running a git pull origin master to ensure you have absorbed any upstream changes

(运行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

If you do not want to merge the upstream changes with your local repository, run git fetch to fetch the changes and then git merge to merge the changes.

(如果您不想将上游更改与本地存储库合并,请运行git fetch以获取更改,然后使用git merge来合并更改。)

git pull is just a combination of fetch and merge .

(git pull只是fetchmerge的组合。)

I have personally used gitimmersion - http://gitimmersion.com/ to get upto curve on git, its a step-by-step guide, if you need some documentation and help

(我亲自使用gitimmersion - http://gitimmersion.com/来获取git上的曲线,这是一个循序渐进的指南,如果你需要一些文档和帮助)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...