0

I created a new xamarin forms project in Visual Studio(Not a new one, took a copy of my old project) and tried to commit the entire project to Gitlab. For that, I created a new project in Gitlab and enter the following commands.

cd project folder
git init
git remote add origin My project remote
git add .
git commit -m "Initial commit"
git push -u origin master

But when I push the new project, it gets committed to my old project. I have given the new project remote but it gets pushed to the old one(New project is a copy of old one).

Is there anyone faced this type of issue from Gitlab? Is there any file from gitlab to be saved to the old project? Why my new project commit redirect to the old one?

Gerald Versluis
  • 30,492
  • 6
  • 73
  • 100
Sreejith Sree
  • 3,055
  • 4
  • 36
  • 105
  • Possible duplicate of [How to migrate GIT repository from one server to a new one](https://stackoverflow.com/questions/1484648/how-to-migrate-git-repository-from-one-server-to-a-new-one) – djuarezg Jan 30 '19 at 11:28

1 Answers1

1

Navigate to local repository and execute:

This command change the origin of your repository.

Tiago Crizanto
  • 314
  • 8
  • 22
  • 1
    Git installed on your machine? "git remote -v" display the remote for the current repository. The second command I change your origin. Check if you have an internet connection or if you're behind a coorporate proxy. – Tiago Crizanto Jan 30 '19 at 13:27
  • Don't know why `git remote add origin` or `git remote set-url` not worked? – Sreejith Sree Jan 30 '19 at 14:13
  • In my anwser the first option is the command "git remote -v" and I explained that this command list your current remote address. – Tiago Crizanto Jan 30 '19 at 16:04
  • When I push the new changes I am getting following error: `hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.` – Sreejith Sree Jan 31 '19 at 05:27
  • 1
    See topics in https://stackoverflow.com/questions/25237959/updates-were-rejected-because-the-tip-of-your-current-branch-is-behind-hint-its – Tiago Crizanto Jan 31 '19 at 12:01
  • Thank you very much. One last question: My commits are pushed to my another project, is there any way to remove the last push happen in the old project? – Sreejith Sree Jan 31 '19 at 14:26
  • Use git revert command. In this blog post you can find more details https://code.likeagirl.io/how-to-undo-the-last-commit-393e7db2840b – Tiago Crizanto Jan 31 '19 at 16:08