Skip to content

Git Problems and Fixes

Jack Evans edited this page Aug 20, 2016 · 21 revisions

Use this page for FAQ and problems with using Git and ways how to fix them for others to see and learn.

Quill's Git tutorial

Quill's Updated Git Tutorial

Git Commands


#Git with GUI Many of you would like to skip the command line in order to help with the project.

Here is the solution, Source Tree, it's a simple way to view the project's progress, and it's available for Mac and Windows. [//]: # (removed "only avialiabe" because mac and windows are the only OS's that unity supports, so if you don't have either, you can't really contribute to the project at all )

You'll have to fetch the master form TeamPorcupine (master) and then merge with your local master before you merge your "feature" branch every time you want to push. (I recommend fetch and merge and not straight up pull because if it happens that you are on the wrong branch you wouldn't lose anything). ###!!Tutorial Coming


[WIP by @bjubes] Help! I added a file to my PR by accident!

Many people have been having this issue, so hopefully this section can solve your problems.

###Prevention The best way to avoid adding extra files to your pull request is to never add them to your commits. Before you create a commit, check what is going to be added by looking at what is checked off in your GUI.

GUI Staging Area

Uncheck files that you do not want to include before you commit, and they will never end up in your PR

###Removing Files Warning! this is an advanced git feature, so it may be easier to start over again in a new PR for smaller changes

If your PR has additional files already, you must locate the commit where the files were added and rebase your PR to remove them. Rebase is potentially destructive, so use care to follow this tutorial exactly. If you are unsure of how to rebase to fix your specific issue, don't hesitate to ask @bjubes in your PR.

  1. Rebase is easiest to do in the command line, so lets open it.
    • On Windows open git bash by typing "git bash" into search or by right clicking inside the root of Project Porcupine and finding the git bash option in the context menu.
    • On mac, open Terminal.exe from spotlight.
  2. use the cd command to change directories until you are at the root of Project Porcupine.
  3. switch to your PR's branch by typing git checkout <feature-branch-name>
  4. type in git rebase -i HEAD~3, replacing "3" with the number of commits ago you added the files you need to remove.
  5. Vim will open a new file that will let you modify your previous commits. Vim is not very intuative, so follow along carefully.
  • when vim opens, you cannot directly edit the text as if in a word processor like notepad. Instead you must first hit the a key to get into insertion mode. When you hit a, --INSERT-- will appear at the bottom left of the screen.

    Insert Mode in Vim

  • if you added files in a commit and want to delete that commit in its entirety, use the arrow keys to move the cursor to the line the commit is on and delete it. In this case I will delete Update GIT_TUTORIAL.

    Deleting a commit

  • if you added files in a commit and want to modify the commit, but not delete it entirely, change pick to e on that line.

    editing a commit

  1. once you are done choosing which commits to delete or edit, hit esc to exit --INSERT-- mode. To save your changes type in :wq (this should appear on the bottom left as you type) and hit Enter. If you messed up, delete everything in the file to abort by holding down d until the file is only ~. Then save with :wq.

  2. If you deleted commits only, you are done! finalize your changes by committing git commit -m "remove extra files" and pushing git push -f. This will permanently delete the commits you selected in step 5. If you chose to edit commits, read on.

  3. When you save in Vim, the console will then tell you to how to proceed.

    Rebase edit

  4. remove files by using the command git rm <filepath> and then type git rebase --continue when you are done. type :wq when the commit appears in vim. 10.keep removing, continuing, and saving the new commit until the rebase is done. Then go back to step 7.