如何将我在分支中所做的更改推送到 master 分支?

How do I push changes I made in a branch into the master branch?

没有远程仓库。

我的本地机器上只有一个存储库。

这就是我所做的:

git branch new-branch
git checkout new-branch

//implemented some changes

//now wants to push changes to master
//what is the command?

这听起来像是我在吹毛求疵,但在 git 中(因此在 git 文档中)你所说的你想做的并不是“推”的意思.

您要做的是将您的更改“合并”到 master 分支中。有关基础知识的说明,请参阅 git merge 文档。 https://git-scm.com/docs/git-merge

您正在将您的提交合并到 master,而不是推送它。推送是为了将您的本地更改发送到远程。

git branch new-branch  #creates a new branch
git checkout new-branch #switches to the new branch

# implemented some changes
git add somefile #stages your changes for next commit
git commit -m "implemented some changes" #commits those changes with message

# push* (it's merge) changes to master
git checkout master #switches back to master branch
git merge new-branch #merges your changes from new-branch back into master

有关详细信息,请参阅 https://git-scm.com/docs/git-merge

据我了解,您要做的是将您的分支与主分支“合并”。 所以请尝试以下操作。

git branch new-branch
git checkout new-branch

//implemented some changes

//to push chages to master first checkout to master
git checkout master
git merge new-branch