IF YOU HAVE COLLABORATOR PERMISSIONS, DO THIS:
No. Don't run away.
In your terminal, type:
As often as you want to. It will give you clues about your next steps in any type of git workflow.
git status, early and often.
I make sure I am in the master branch of my team's shared repository & that I have the LATEST VERSION:
git pull origin master
I make my very own branch. You can make one from the Github site but I prefer to do it in Terminal/bash. I name it a name with no spaces, like: "mybranchname". It's best to name it after a feature or fix you're working on.
git checkout -b mybranchname
Now I am in my branch, not the master, so it is safe to make changes.
I code away in my code editor, tappity-tap.
I add my changes:
git add file-name-here
Then I commit the changes:
git commit -m 'my awesome improvements to our life-changing app'
If I only want to push changes to the local copy of my branch (see step 8 below, for the better method)
git push origin mybranchname
If I want to push changes to a remote reference to my branch, one where changes are being tracked every time. (This is what I want!)
git branch --set-upstream-to=origin/mybranchname mybranchname
If you ran
git status you would know now to:
Warning: you can only use 'git push' if you set the origin mybranchname to track your mybranchname locally. otherwise use the method in step 7
But hold up. I want to resolve conflicts with the master branch, in case anyone has been working in it, and I want to resolve them before I make a Pull Request.
git pull origin master - yes from right inside my branch!
This will both fetch my parent branch (in this case master, but it could be some other parent development branch, too) and merge it with my current branch! Remember to fix any merge conflicts now!
If you ran
git status again, you would know to:
git push to push the merged changes to your local branch.
If I get a prompt that I need a commit message to explain the merge, I can exit the editor with
Shift Z Z
I go to my remote repository github.com
Once there, I see in our shared repo, a 1 (or any number of requests) under "Pull Requests", so I click to go to that page.
I click on my pull request to open it up, and then I click the green confirmation button, and click again, until I have satisfied all of the options to confirm the merge. If there are conflicts, I resolve them before confirming everything.
No more green, you will now get an alert that is purple, telling you the merge is complete. It will ask you to delete the branch. Go ahead and do that. It's best to use new, descriptively named branches for bugfixes and features, then delete them after merging.
In my terminal (or git bash for PC,) I switch to my master branch
git checkout master
Just in case, I refresh my master branch again using
git pull origin master, to make sure I am up to date with my changes and also with any other changes that people made concurrently.
In my terminal, I delete the local version of the branch I SUCCESSFULLY merged & had deleted remotely on github.com.
git branch -d mybranchname
I want to make a new branch and start this cycle all over again from STEP 1.