简体   繁体   English

如何将更新推送到github中的分支

[英]How to push update to a branch in github

Let me know what I am doing wrong here ? 让我知道我在这里做错了吗?

When I am doing $git status it is showing my branch as * my_branch 当我做$git status它显示我的分支为* my_branch

Now I changed in few files and trying to push updates to the branch so I tried two things - 现在我更改了几个文件,并尝试将更新推送到分支,所以我尝试了两件事-

1) First try 1) 第一次尝试

$ git add .

$ git push origin my_branch

This is showing Everything up-to-date 这显示Everything up-to-date

2) Second try 2) 第二次尝试

$ git add .

git commit -m "first commit"

Now on running this I am getting following error - 现在在运行它,我得到以下错误-

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'trialcoder@sysuser.(none)')

There are a few things going on here. 这里发生了一些事情。 First, you need to understand the difference between add and commit. 首先,您需要了解添加和提交之间的区别。

add stages your files for tracking. add阶段以跟踪文件。

commit submits the changes, and untracks the file. commit提交更改,并取消跟踪文件。 (The idea is that you are done with it now.) (想法是现在就完成了。)

On your first try, you added the files to track, but didnt add any changes to version control. 第一次尝试时,您添加了要跟踪的文件,但没有对版本控制添加任何更改。 When you do push , it pushes your commits. 当您执行push ,它会推送您的提交。 Because there were no commits, it said everything was up to date, which is correct. 因为没有提交,它说一切都是最新的,这是正确的。

Second, you tried to commit your changes. 其次,您尝试提交更改。 Git requires an email address from a user in order to submit changes. Git需要来自用户的电子邮件地址才能提交更改。 This is so you know who made the change. 这样您就知道是谁进行了更改。 You have not yet told git your email address, so it is requiring you to do so before a commit will succeed. 您尚未告诉git您的电子邮件地址,因此要求您这样做才能成功提交。 All you need to do, is do the command the message told you too. 您所需要做的就是执行消息也告诉您的命令。 Use any email/name you like. 使用您喜欢的任何电子邮件/名称。 If this is for a company, you should probably use your @company email address. 如果是公司,则应该使用@company电子邮件地址。 If this is for github, you should use the email that you used to sign up with github. 如果这是针对github的,则应使用用于注册github的电子邮件。 Otherwise, it doesnt matter, just use one that is you. 否则,没关系,只使用一个就是你。

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

Then proceed with a commit: 然后继续执行:

git commit -m "first commit"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM