Spandan Spandan - 6 days ago 7
Git Question

how to copy and replace some project files in a branch only in git

I have created a new project repository in bitBucket and I have the local copy also. Now, I have created a branch from master called "xyz".

Before I had created another project repository and me and my team member worked on this repository. I was working on master repository and one of my team member has checkout it (I as admin has added him in bitBucket) locally and continued working locally. After that he sent me the complete project folder.

No as mentioned above due to many conflict problems, I created another new repository in bitBucket and put the files and folders from the master in my old repository into it. Now I have created a branch in the new repository and I would like to put the files and folders (many files and folder will be redundant and I would like to replace all of these redundant files and folders into this branch "xyz"), my team member sent into this branch only ("xyz").

Could anyone please help me with this problem. I don't know how to do it locally in git and then to push it into the specific branch at remote.

Answer
  • Say your first repo name is repo-1 and new repo name is repo-2. Now go to both repo-1 and repo-2 then checkout master branch.

    $ git checkout master       # checkout master(repo-1)
    $ git checkout master       # checkout master(repo-2)
    

Now copy all of your repo-1 folders/files (except .git folder) and paste inside repo-2.

  • Then repeat the procedure after changing both of repo's branch to xyz.

    $ git checkout xyz       # checkout xyz(repo-1)
    $ git checkout xyz       # checkout xyz(repo-2)
    

Now copy all of your repo-1 folders/files (except .git folder) and paste inside repo-2.

Comments