How do i clone work from the master branch to a new one?

zedge

I've been working on the master branch. Now i want to pull all the work to a new branch i just created to continue working there.

Im new on git, and the idea is to work on a branch and just merge it on master until my code pass(im on school). But i already started and had made lots of progress that i dont want to lose.

I already git checkout but it just returns me a blank readme.

quyetdc

From your description I can imagine that you're working on the master branch, but it seems that you haven't added changes and you haven't created any commit ( I guest only ) In that case, you can just create a new branch

git checkout -b new_branch_name

In case you committed your work into commits in master branch and already pushed it to Github (ignore below commands if you haven't), you can back to master branch reverse it

git checkout master 
git reset --hard HEAD~HERE_NUMBER_OF_YOUR_NEW_COMMITS
git push origin master -f
git checkout new_branch_name #To continue work on new branch (with all your new works remained)

Then, commit changes ( this should be repeated many times when you have completed sth

git add .
git commit -m "I created new feature"
git push new_branch_name

And then, from Github, you can create a pull request so your tutor / teammate can review

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Doing a clone of master, feature branch from that, and during time merging updates from clone branch into feature branch - can i do a rebase?

Clone Branch and create a new from the first one

How do Git branches work? Can I remove the master branch?

How can i avoid bringing changes from new branch to master

How do I create release branch from master, excluding particular branch which is already merge in master

How do I make a pull request from the master to the staging branch?

How do I pull changes from a branch in master to a subbranch?

How do I keep files in a branch if they are removed from master?

Do I want to clone a branch of origin master directly into eclipse?

How should I branch out two work items, one is enhancing master, the other is enhancing the first one?

How do I clone a single branch in Git?

How do I clone a specific Git branch?

With Git, after my code commits are merged to the master branch, do I delete my remote branch, clone master again and checkout the next branch?

how can i know on which git branch I am when I do git clone from dockerfile

How do I use git svn to clone more than one branch, but not all?

new git branch from existing one without merging with master

New Branch has had many changes - how do I merge into Master?

How do I create a new Git branch from an old commit?

How do I push a local Git branch to master branch in the remote?

How do I copy commits from one branch to another?

How do I assign a commit from one branch to another?

I want to enable deployment only from the branch names(starting with hotfix and master). How can I do that?

How can I create a new git branch from the base of the commit tree , which has no commit in common with master branch ? for gh-pages

SVN How can i add 2 new files from one branch to another branch?

How can I remove files from one Git branch and add them to a new branch

How do I move a commit from master to a branch while preserving its Gerrit ID?

How do I push up my changes to a master git organization from a forked copy dev branch?

In Git, How do I checkout to a New Branch from an already Existing Branch?

I cloned a remote branch. How do I checkout master?