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

Categories

0 votes
560 views
in Technique[技术] by (71.8m points)

git - 如何将特定提交推送到远程,而不是之前的提交?(How can I push a specific commit to a remote, and not previous commits?)

I have made several commits on different files, but so far I would like to push to my remote repository only a specific commit.

(我已经对不同的文件做了几次提交,但到目前为止,我想将我的远程存储库推送到特定的提交。)

Is that possible?

(那可能吗?)

  ask by Robert23 translate from so

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

1 Answer

0 votes
by (71.8m points)

To push up through a given commit, you can write:

(要通过指定的提交推 ,你可以这样写:)

git push <remotename> <commit SHA>:<remotebranchname>

provided <remotebranchname> already exists on the remote.

(提供<remotebranchname>已存在于遥控器上。)

(If it doesn't, you can use git push <remotename> <commit SHA>:refs/heads/<remotebranchname> to autocreate it.)

((如果没有,你可以使用git push <remotename> <commit SHA>:refs/heads/<remotebranchname>来自动创建它。))

If you want to push a commit without pushing previous commits, you should first use git rebase -i to re-order the commits.

(如果要在推送先前提交的情况下推送提交,则应首先使用git rebase -i重新提交提交。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...