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
4.2k views
in Technique[技术] by (71.8m points)

git - copy files from master to new branch

I have been working on a project for a customer. The customer is now asking me to upload the stuff I am working on their github account. I dont want to change their setup, I would like to create a new branch. On my local machine I have done the following. When I do a git status I get that working tree is clean. How can I push all the files from master to devBranch to be able to upload just this branch and not interfere with the customer's master branch?

git add.
git branch dev_branch
git checkout dev_branch

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

1 Answer

0 votes
by (71.8m points)

I don't see a git commit in your sequence.

The usual way is:

cd /path/to/local/repo
git switch -c new_branch master
# work
git add .
git commit -m "New work on new branch"
git push -u origin new_branch

If you don't have the right to push back to the original repository, then you would need to fork it first.


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

...