Search code examples
gitgithubgit-bashgit-push

Git push, what should be the branch name?


EDIT : Thank you all for help, My intention for this question was basically on the lines of Shared repository model

A newbie to github.

I have cloned a branch from github using the command

git clone -b amigo --single-branch <git_path.git> localFolderName

I then cd to localFolderName and do a

git pull

Next, I create a local branch

git branch beautiful_branch

followed by

git checkout beautiful_branch

I then make all the changes to the code, do a

git add <fileName> <fileName2>

and then do a commit

git commit -m "My first commit"

Now the Question is, I want to commit my beautiful_branch to amigo and do a pull request. I am not sure what should be my push command ?

if I do

git branch -a

It shows me

*beautiful_branch
amigo
remotes/origin/amigo

I have tried

git push -u amigo beautiful_branch

and

git push -u origin/amigo beautiful_branch

but I get fatal error

fatal: 'amigo' does not appear to be a git repository

fatal: Could not read from remote repository.

It would help if you could let me know what should be the git command to push to the amigo branch.??

EDIT:

I am following all the above steps so that I can do a pull request from github and ask for a review to my code before it is being merged.


Solution

  • First you have to merge amigo and beautiful Branch. For that

    1. Checkout out to Amigo

      git checkout amigo
      
    2. Merge amigo and beautiful-branch

      git merge beautiful_branch
      

    Now you have beautiful_branch changes in amigo. To push these to your origin, do

        git push origin amigo
    

    EDIT:

    Since you need to merge beautiful branch with amigo by somebody's review, you have to push from your local beautiful_branch to your origin beautiful branch and then raise a pull request from beautiful branch to amigo branch.

    1. Commit your changes to beautiful_branch
    2. push your commits to your origin beautiful_branch

      git push origin beautiful_branch

    3. Now you can goto github, choose your branch (beautiful_branch) by default its selected as master.

    4. next to that you will find New pull request, in the next page choose your base branch to merge which is amigo.
    5. Give the description for your changes in the branch raise a pull request.

    That's it. whoever has the privileges to merge, will merge it to amigo after review