newtfire / textEncoding-Hub

shared repo for DIGIT 110: Text Encoding class at Penn State Erie, The Behrend College
https://newtfire.github.io/textEncoding-Hub/
Creative Commons Zero v1.0 Universal
16 stars 0 forks source link

i [Esc] : w q (How to resolve a Merge Issue) #44

Closed ebeshero closed 2 years ago

ebeshero commented 3 years ago

If you try to send a git push to a shared GitHub repo before you have pulled in recent updates from others, GitHub will prevent you from pushing, and you may see a message like this:

" Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again."

When you enter git pull you may get a message in a new window indicating you need to "Merge" the remote's changes with yours . When that happens, you want to treat it as a commit that git has automatically made for you, to reconcile all the changes. Git gives you a commit message at the top of that Merge screen, and you can complete the commit with these keystrokes:

  1. Type i : This lets you type in the window ("i" stands for "insert"): you can move your cursor and edit Git's automatic commit message, or leave it alone. But "i" puts you in the window so you can act.

  2. Now press these keys in sequence: [Esc] : w q (The [Esc] key is on the top left of your keyboard. The : is to the right of the letter "L" and you need to use shift key to select it.) This sequence means: Escape the window, and write (save) this commit, and quit. You'll see the : w q appear at the bottom of the Merge window. Hit enter, and you should go back to your usual command line prompt.

  3. When you're back at your normal command prompt, type git status. You will probably be invited to push 2 commits. One is the commit you originally tried to push. The other is the commit that git made to merge the remote changes with your changes. Go ahead and git push and all should be well with GitHub.