0

I'm very nooby to using git branches with other users so I was hoping for some help regarding a project. My project has 3 branches(master, auth, and dev1). I am the user of the master branch and I recently cloned the auth branch to a local folder and edited it.

My question is...How do I (push?) my corrections to the auth branch and merge it with the master branch? Can I just (merge?) the edited auth branch with the master locally?

aka

Phil owns *master

Bob owns *auth

Phil clones *auth to local computer. Edits *auth and wants to then merge edited *auth with *master.

pjmanning
  • 1,241
  • 1
  • 20
  • 48

3 Answers3

1

You can simply go to the branch you want to add your changes to (git checkout master) and merge your changes to it (git merge auth).

here's the general order:

Assuming auth and master are identical right now:

git checkout auth you are now on auth branch -

make some edits and commit (git commit -m 'awesome changes to auth branch')

git checkout master you are now on your unchanged master branch

git merge auth if all things work out, your changes made in auth will be merged onto your master branch

git push


AFAIK (and believe me, I'm new to this too), you will have problems if your friend adds similar changes to master branch before you merge. If this happens, git will not know who's changes to save during the merge: yours or his?


I'd also HIGHLY recommend reading the book 'Pro Git' . It's free an easily found online. It's very easy to read and really helps everything make sense.
d-_-b
  • 21,536
  • 40
  • 150
  • 256
0

Since you have the master up to date, I think this will do what you want:

git checkout master
git merge auth
git push origin master

Go to master, merge auth into it, then push it to the remote.

BUT this way you won't update the remote auth, so you'd better push your commits first:

git push origin auth
0

My question is...How do I (push?) my corrections to the auth branch and merge it with the master branch? Can I just (merge?) the edited auth branch with the master locally?

You push your corrections to the auth branch with this following command (let's pretend the name of your remote repository is "banana"):

git push banana auth

If I'm reading your question correctly, you want to push your branches, THEN merge them. You can't do it in that order. It has to be "merge, THEN push." You can only merge "locally", then push the changes to your remote repo using the command above.

By the way, for each branch, use the following command at least once:

git push -u <branchName>

This will associate your local branch with the remote one so you don't get any annoying messages saying "You don't have a default branch, waaaah!" or whatever that message is if you want to push ALL of your branches at once.

As far as merging, the responses above have answered that.

Hope this clears some things up!

gitlinggun
  • 108
  • 6