git 如何将此修改后的文件推送到 github 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35559968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:57:15  来源:igfitidea点击:

how to push this modified file to github repository

gitgithub

提问by nh Dalim

how can i push this modified file in github

我怎样才能在github中推送这个修改过的文件

% git status
    # On branch master
    # Changed but not updated:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working
    #   directory)
    #    modified:   login.php
    no changes added to commit (use "git add" and/or "git commit -a")

回答by Prashant Srivastav

git status 

It will show you all modified file and new file in working tree

它会在工作树中显示所有修改过的文件和新文件

modified:   file path

Untracked files: that are not tracked by Git

未跟踪的文件:Git 未跟踪的文件

For adding Untracked files

用于添加未跟踪的文件

git add <file path>

after adding file you need to commit

添加文件后,您需要提交

 git commit -m "< your message>"

For committing only modified file

只提交修改过的文件

git commit -m "<your message>" <file_path 1> <file_path2>

Pushing code to git

将代码推送到 git

git push <origin> <branch_name>

Update remote refs along with associated objects

更新远程引用和关联对象

For more details read documentation

有关更多详细信息,请阅读文档

回答by Mureinik

Your current status is that you performed a change in a file that git is tracking, but haven't done anything with this change. So first, you should "tell" git about this change, or stage it to be committed (note that you can stage several files/changes at once):

您当前的状态是您对 git 正在跟踪的文件进行了更改,但尚未对此更改进行任何操作。因此,首先,您应该“告诉”git 有关此更改的信息,或者将其暂存以进行提交(请注意,您可以一次暂存多个文件/更改):

% git add login.php

Once that is done, you need to commit this change, and add a message explaining what this change contains:

完成后,您需要提交此更改,并添加一条消息说明此更改包含的内容:

% git commit -m "Fixed bug in login.php"

You can now proceed to push this change to github:

您现在可以继续将此更改推送到 github:

% git push origin my_branch