使用git编辑远程分支

时间:2013-09-20 04:07:16

标签: git

我正在学习git而且我完全迷失了:

我想做以下事情:

  • 我想使用git来获取和编辑(推送)远程分支。

我该怎么做?

我正在考虑做以下事情:

git branch -a
then 
git checkout remote/branch_name
git add .
git commit -m "..."
git push (which would push to the remote)

这是你怎么做的>

1 个答案:

答案 0 :(得分:-1)

如果更改存储库的历史记录,则将拒绝远程推送。你必须强行推动。

你正在使用的git命令

git branch -a
then 
git checkout remote/branch_name
git add .
git commit -m "..."
git push (which would push to the remote)

可以向存储库添加新提交,但不会更改历史记录。

您可以使用

重写历史记录
git rebase -i <commit>

然后推送到远程仓库

git push --force origin <branch>