Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

Push uncommitted local git changes to a new remote fork

I have a local git repo (call it local master) associated with a remote (master) repo. I have uncommitted changes in my local master. I want to:

  1. push the local master changes to a new (remote) fork.
  2. continue to work on the local master changes, and then push it to the remote master.

Can I do this without creating a local copy of the remote fork? If I must create a local copy of the remote fork, is there a way to git copy the changes from local master to local fork? (I mean avoid doing cp localMaster/changedFiles localFork/changedFiles).

Why am I doing this? I have ugly but working code locally. Before I clean it up, I thought I should stash it away in a remote fork, in case I needed to look at the different things I tried before I got it to working. I wasn't sure branching was a good idea for this purpose.

question from:https://stackoverflow.com/questions/65894177/push-uncommitted-local-git-changes-to-a-new-remote-fork

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

1 Reply

0 votes
by (71.8m points)

A local repo can have multiple remotes that it can push to. So just create a new remote repo, add that as a remote to your local repo, and push any branches that you care to. If you create the remote repo at GitHub, for example, they give you instructions, right there, for doing exactly that.

Note that you cannot push uncommitted changes. Uncommitted changes are not "things" in Git. Only commits are "things". Uncommitted changes are just you talking to yourself, as it were.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...