Basic Workflow

Updated on 28 Dec 2018

  • git add --all add all the files in the workspace to the staging area ready for the local repo
  • git commit -m "a quick message" commit the files in the staging area to local repo with the message a quick message
  • git push push the files from the local repo to the remote repo.
  • git fetch bring my local copy of the remote repository up to date
  • git merge merge the changes from the local repo into the workspace
  • git pull pull and merge changes into the local repo and workspace

pull vs fetch

A pull is like doing a fetch and merge at the same time. fetch has the added bonus of retrieving remote branches into your local repo, whereas a pull will only update the branches that are in your local repo.

Updating workspace when you have unstaged files - 1

If you have unstaged files and wish to update your repo / workspace with the latest code from the remote repository, you can simply do a git pull.

Updating workspace when you have unstaged files - 2

If you have unstaged files and those files have been changed on the remote repository, then git will not merge those changes.

I either have to commit the changes, stash them, or rollback (reset) my changes.

git reset --hard HEAD

Updating workspace when you have committed files

If you have files that have been committed, but not pushed, you can also update your workspace. However because your commit is different to what is being pulled from the repo, git will do a merge.

If the files that you have committed are the same as the files that have been modified remotely, then you might encounter a conflict if the same line of code has been modified by both yourself and the remote repository.

It is at this point that we now need to look at kdiff3 and deal with the merge conflicts.