0

How do i push my code to a remote branch which has already been created?

I need step by step method of how to push to a remote branch? I have a remote repo. So i want to push to a branch in the same Repo

For instance , the Repo is given as https://github.com/tarana/Backend.git with a branch name of shuri. How do I push to that shuri branch?

New to this. Please i need step by step guidance.

What i have tried?

I did git push shuri

and it gave me this as response

fatal: not a git repository (or any of the parent directories): .git
Keros
  • 1
  • 5
  • the command to push is `git push` - usually just that would work. Did you tried to find git documentation for guidance on the parameters of this command? – Leonardo Alves Machado Dec 02 '21 at 19:07
  • i did , it gave me a Fatal Error – Keros Dec 02 '21 at 19:07
  • Does [this](https://git-scm.com/docs/git-push) helps you? – Leonardo Alves Machado Dec 02 '21 at 19:08
  • Have you set up the upstream ? You need to provide more context. What you tried and what didn't work out. – Asif Kamran Malick Dec 02 '21 at 19:09
  • @LeonardoAlvesMachado git documentations are certainly not beginner friendly. The OP is new to git asking for guidance here. – Asif Kamran Malick Dec 02 '21 at 19:12
  • If you have a local branch and need to push changes to another remote branch, you need to do some setup to help git establish a relationship between your local branch and the remote branch. Its usually a one-liner command. This answer should help you : [Getting existing git branches to track remote branches](https://stackoverflow.com/a/5172032/2915738) – Asif Kamran Malick Dec 02 '21 at 19:19
  • It seems you are not in a git folder... – Leonardo Alves Machado Dec 02 '21 at 19:19
  • how do I push to an existing Branch on a Repo? the Repo is existing with name as Shuri – Keros Dec 02 '21 at 19:24
  • @LeonardoAlvesMachado how do i get to a git folder – Keros Dec 02 '21 at 19:24
  • looking at the error it hints that you are not performing the action inside a git repository. Your project should have a `.git` directory as pointed out by @LeonardoAlvesMachado. Do you see any such directory? If not you need to initialize your project with `git init` so that it becomes a valid git project and then proceed with usual git commands to create branches, `add` changes, `commit` and `push`. – Asif Kamran Malick Dec 02 '21 at 19:24
  • A `.git` directory is usually hidden. If on Windows, check `Hidden Items` in the view tab of File Explorer. If on Linux or using git bash terminal just go to the project location and type `ls -a`. – Asif Kamran Malick Dec 02 '21 at 19:29
  • done the git init, then how do i push to an existing repo branch? – Keros Dec 02 '21 at 19:36
  • This should help you get your job done : [How to upload a project to Github](https://stackoverflow.com/questions/12799719/how-to-upload-a-project-to-github) . Also keep this handy for future reference :[how-to-ask-on-stackoverflow](https://stackoverflow.com/help/how-to-ask). Stackoverflow community is pretty serious about quality of questions. Its totally understandable that you are new to the platform. But asking good questions helps in the long run. People will be really willing to answer if the question reflects some research effort. – Asif Kamran Malick Dec 02 '21 at 20:34
  • 1
    Can I suggest you follow some git courses? E.g. https://lab.github.com/githubtraining/introduction-to-github. Key here is that if you have an existing project on github, you should not need to go anywhere near "git init" but should be using "git clone" to pull down the existing repo. You have to add your changes on top of the existing commits - that is the way git works. I think you are just not using the tools properly and inevitably will have problems. – johnfo Dec 03 '21 at 06:32

0 Answers0