Snippets

Robb Gosset Git cheat-sheet

Created by Robb Gosset last modified

To Login:

If you are using a UWE computer on windows:

  • Open Putty and enter milly.cems.uwe.ac.uk into the address box and click connect
  • Type in your UWE username and press return
  • Type in your UWE password and press return (nothing will show on screen as you type)
  • Type cd /your/repo/path

If you are using a non-UWE computer on windows:

  • Open Putty and enter ras.cems.uwe.ac.uk into the address box and click connect
  • Type in your UWE username and press return
  • Type in your UWE password and press return (nothing will show on screen as you type)
  • Type in ssh milly.cems.uwe.ac.uk and press return
  • Type in your UWE username and press return
  • Type in your UWE password and press return (nothing will show on screen as you type)
  • Type cd /your/repo/path

If you are on Linux then replace Putty with a terminal SSH client.

To see what's changed:

  • Type git status this will show what files have changed and what's staged for commit

To commit your changes:

  • Type git add followed by the files that you have changed (remeber directory names if they are in folders, eg 'images/banner.png') (You can use git add . to add all files that have changes)
  • Type git commit -m "<<description of changes here>>" and press return to commit changes to your local copy

To push changes to the cloud:

  • Type git push and any commits you have made since your last push will be sent to the cloud.
  • If you get a message similar to the following: ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@bitbucket.org:rmadsaa/twin-cities.git'
  • Then you must do a pull because someone else has pushed commits to the cloud since you last synced.

To pull changes from the cloud:

  • Type git pull and any new commits in the cloud will be pulled and merged with your local copy.
  • If you get a message similar to the following:

    CONFLICT (content): Merge conflict in contributors.txt
    Automatic merge failed; fix conflicts and then commit the result.
    
  • Then there are merge conflicts, open the files named by git in the error message and find the merge conflicts, they will look like the following:

    <<<<<<< HEAD:mergetest
    This is my third line
    =======
    This is a fourth line I am adding
    >>>>>>> 4e2b407f501b68f8588aa645acafffa0224b9b78:mergetest
    
    <<<<<<< : Indicates the start of the lines that had a merge conflict. The first set of lines are the lines from the file that you were trying to merge the changes into.
    ======= : Indicates the break point used for comparison. Breaks up changes that user has committed (above) to changes coming from merge (below) to visually see the differences.
    >>>>>>> : Indicates the end of the lines that had a merge conflict.
    
  • Look at the linex between the indicators, manually change them to resolve the confilct, save the file and commit and push your changes.

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.