How to revert a branch back to a private github relay

I have cloned a private repo in github to my local machine. After I make some changes, I want the branch to go back to github to suggest a merge (or a pull request, as github calls it).

How to do it?

I am completely new to github (I usually use bzr / launchpad, and command bzr push lp:~<username>/<master-branch>/<name of the new child branch>

. What is the equivalence of this in git

?).

[Edit: I found my wording to be confusing due to my little understanding of git terminology, I'm going to rewrite what I did)

( bar

is a private repo)

$git clone git@github.com:foo/bar.git
$cd bar
$touch <some file> # ie., make some changes
$git commit ...
$ <<<<< NOW I need to push this back to github here.

      

+3


source to share


2 answers


From your comments above and your original question, you want to make a pull request to github, but you changed your local address master

... that's the problem. What you wanted to do was check in branches first, commit changes, commit locally, and push the branch. Then you can create a pull request to github from that thread.

First, what you need to do to fix this:

git branch mytopicbranch
git reset - rough origin / master

You now have a branch and reset locally master

what the remote repo has. You can now push your branch with:

git push origin mytopicbranch

Then on github you should be able to create a pull request for that branch.



A normal flow would have to do the following:

git clone <remote repo> 
<cd to directory>
git checkout -b mybranch 
<make changes> 
<commit changes>
git push origin mybranch
<create pull request on github>

      

Edit to add: This is at your request; wanting to make a "pull request". If you just want to push master

, you just do:

git push start of original

And your changes will be about remote control.

+3


source


The private master repo does NOT belong to me (i.e. I do not have permission to put my repo back to the master repo). I think I can only get my local repo back and ask the owner to merge it with master

You seem to be confusing a lot of things here. First of all, the repository is a single whole. When you clone a repository, you get a complete local copy.

If you have cloned a repository that does not belong to itself and for which you do not have write permissions, then you will not be able to make any changes to that repository. If so, you need to develop it first on your own GitHub account. To do this, click the Fork button in the repository view. This will create a copy of the repository in your own account, to which you have push rights.

So, if you have a local clone of the repository, you can do whatever you want. Nothing affects the remote repository, neither the original nor your GitHub fork. You can create as many branches as you want and commit whatever you want. Note that branches are not some construct in Git. Branches are simple pointers to commits, so creating a branch doesn't do much and won't affect your structure unless you actually start committing.

If you have a commit that you want to push to the remote repository, you can do so using git push

:



git push <remote> <local-branch>:<remote-branch>

      

So, if you want to push your local branch master

to a branch test

on a remote server named origin

, you can do git push origin master:test

. When you push directly to a remote branch test

(which shouldn't have existed before), you won't be touching the branch master

. The other options git push

are just abbreviations for the above command. For example, git push <remote> <branch>

which is probably the second most common way of pushing actions, will push your local branch <branch>

to a remote tracking branch (usually with the same name). Thus, it is more or less equivalent <branch>:<branch>

. The most common way is simplygit push

which will define remote and branches on its own based on your configuration, but to be safe you can just specify it explicitly.

So going back to your use case, I am assuming you want to rewrite some elses repository to make changes to it and suggest that change to the original author as a pull request. To do this, you must follow these steps:

  • Push the repository to GitHub
  • Clone your own repository (i.e. fork)
  • In your local repository, make your changes
  • Push the changes to your fork (any branch is fine, although a separate branch is recommended for clarity)
  • When viewing a fork on GitHub, click on the pull request button to create one based on your pushed branch.
+2


source







All Articles