0

My friend and I have a remote branch in Gitlab. For some reason I got the project from my friend by copy-paste (I know that's a bad thing). But let's say I got the code, did some changes, and I want to initialize git in it and then push a new branch in our project. Like:

  1. Get the project from my friend
  2. Do some changes in the code
  3. git init in the project folder
  4. git remote add origin https://...
  5. git fetch
  6. In this step, I want to create a branch, say foo-branch. Commit my changes, and push it to origin foo-branch, with the background commits of master (or any other branch).

What is the right way to do step 6? I have tried that after step 5, I tried git reset master so I can get all the older commits from master branch but it didn't worked.

I can give more information if you need.

Edit 1: After step 5, I did git reset origin/master. It seems like it's something to move on, git log shows all the previous commits. But this time git status shows all the files even those in the .gitignore. Any ideas how to do this correctly?

emremrah
  • 1,103
  • 8
  • 15

1 Answers1

0

If the tarball contains code you want to push into gitlab, this is what you should do

  1. Clone the repository from gitlab
  2. Create a new branch and checkout to it
  3. Unzip your zip file into the repository (assuming it doesn't have a .git inside it).
  4. Do a git diff to confirm if the changes are correct.
  5. git add, git commit, and git push to the new branch.
Noufal Ibrahim
  • 66,768
  • 11
  • 123
  • 160
  • In step 1 you mean cloning the repo to a completely new folder, and in step 4 you mean copy-paste all the files except `.git` from the zip I got to the new clone I just get, right? – emremrah Jan 21 '20 at 13:28
  • Your solution is actually similar to one of my answers to a question here, right? https://stackoverflow.com/a/58390283/6402099 – emremrah Jan 21 '20 at 13:32
  • Similar. But wait, are you saying you still have the original tarball? In that case you can just extract the `.git` directory you previously (for some reason) deleted. – Useless Jan 21 '20 at 13:57