I am currently working on my android application on android studio and I am fairly new to working on it with git. I have files that I want to move from a branch (branch1) to a completely new branch (feature1). Please note that I have committed all of my changes to branch1 and I have pushed all of those commits as well.
I have seen similar questions with answers but I am quite confused about how to make it work. How can I do that? Thank you and pls bear with me 🙂
2
Answers
You can cherry pick commit that you want to move from branch1 to feature1
Let’s say we have three branch in a repository (master, branch1, branch2).
Now, you want to remove file from
branch1
and that file should be present in a completely new branch saybranch3
Create new branch of
branch1
git checkout branch1
//to create new branch from branch1, you need to checkout to that branch firstgit checkout -b branch3
Now, the new files are in
branch3
.Now checkout to
branch1
and$ git rm <file-name>
and$ git commit -m "file removed from branch"
It’s the simple and straightforward way I can think of.