Reputation: 404
I created a branch called "myBranch" from "origin/develop." I make local changes on myBranch. At the same time, other people are making changes to origin/develop, so I periodically fetch and merge that branch with myBranch (using "git pull"). When I add and commit, then push the changes to the remote repository, which shares the same name as my local branch, using "git push origin master", I'm only seeing my local changes. All the merged changes from origin/develop aren't getting pushed along with my local changes.
Also, how do I tell what "master" is? Is it the branch I'm currently on?? There's obviously something wrong with how I'm pushing myBranch into the remote repository.
Upvotes: 2
Views: 106
Reputation: 404
I figured this out. It's: git push origin HEAD
I think my "master" was pointing to a local branch, so it was never updating the remote repository.
You can view the pointers of master, origin, head, etc. in the .git/config file.
Thanks for all the help!
Upvotes: 0
Reputation: 129744
master is just another branch name. So you are pushing to the wrong one. you should be
git push origin myBranch:develop
the convention is local ref name : ref name on the repo you are pushing to . if you omit the colon and last name, it assumes you mean a remote branch of the same name.
if you add the -u
argument, that will set up the tracking to point myBranch to develop on the server and now you can just
git push
see the config after doing that and you will see how git records this:
cat .git/config
However.. you should really have develop on your own repo. Your workflow would be
git fetch # will grab all the branches from the remote
git checkout develop # will make a local develop branch that points to origin/develop
# do some work, commit, etc
git pull origin develop # this will merge for you
git push -u origin devolop # to set tracking
the last one just needs to be ran once and then you can just git push
.
Also setup git to only push your current branch by default with
git config --global push.default current
otherwise it will push all branches that you have locally if they have tracking set up.
Upvotes: 2