Editing
When you are the only one editing at the time:
When finished with an editing session:
-
Pull: in the terminal window, type
git pull - This merges in any changes someone else made to the repo
-
Commit: in the terminal window, type
git commit -am “your commit message” - This prepares your changes for uploading
-
Push: in the terminal window, type
git push - This uploads your changes to the GitHub repository
Next time you are ready to edit: Pull, then edit as you like, then Commit and Push.
When someone else is also editing (a different part of the file):
-
Commit: in the terminal window, type
git commit -am “your commit message” - This protects your changes
-
Pull: in the terminal window, type
git pull - This merges in what your friend did
-
Push: in the terminal window, type
git push - This uploads your changes to the GitHub repository
If you try pulling without committing, you will get an error.
When someone else (unfortunately) edits the same line as you
You must resolve these differences!
-
Pull: in the terminal window, type
git pull - You will get a “merge conflict” error message
-
Edit your file. You will see something like this:
<<<<<<<<<<<
passage written by person 1
===========
passage written by person 2
>>>>>>>>>>>
- Remove one of the passages, as well as the <<<, ===, and >>> symbols.
-
Commit: in the terminal window, type
git commit -am “your commit message” - This prepares your changes for uploading
-
Push: in the terminal window, type
git push - This uploads your changes to the GitHub repository
Depending on your IDE, there may be more convenient or visual ways of dealing with merge conflicts. It’s always good to check your IDE’s documentation for how it handles merge conflicts.