Internet Commons

Your website development partner

Controls: show

Document Extract

Comments:

[log in] or [register] to leave a comment for this document extract.


Go to: all document extracts

Options: show

Contact:

mail@internetcommons.ca

Website:

[home] [about] [help]

Subsites:
Members:

[profiles]

Document Extract

Notes on GIT handling

30-Apr-2013 [223]

Part of unassigned

git help <command>

  • git status (to see changes in local space)
  • git log (to see git commit history)
  • git diff c6cd9..40abed (to see changes between these two commits)
  • git diff (to see changes in local dir that have not yet been staged)

git mv oldname newname (to rename a source file)

The standard order to do things in:

  • - git add
  • - git commit
  • - git pull (and check for conflicts)
  • - git submodule update (to get Greg's changes to 'user' stuff)
  • - git push

git checkout -- filename (to discard local changes to filename)

  • git reset HEAD1 (to roll back a commit that has not been pushed)
  • git reset --soft HEAD1
  • * in both cases all changes to local workspace are retained
  • * in the former case the files that got committed are put back to
  • 'local modification' status. in the latter, they remain 'staged'.
  • git stash (to record the current state of the working directory)
  • git stash save (equivalent to the above)
  • git stash show (to see what is in the stash)
  • git stash apply (restore the local changes on top of any subsequent commits)

To mark a file as ready to commit: git add <filename>

To commit all "staged" files: git commit

To modify the most recent commit: git commit --amend - this allows you to add more files to the commit and/or modify the previous comment.

http://blog.jacius.info/2008/6/22/git-tip-fix-a-mistake-in-a-previous-commit/

  • don't say 'git commit -ammend' instead. this commits all changes with a comment of 'mend'.

To fetch data from the remote repo and merge it into your workspace: git pull

To "push" commits up to the remote repo: git push origin master (or git push)


Resolving merge conflicts


The conflicted file will contain lines like...

<<<<<<< HEAD:file.txt
Hello world
=======
Goodbye
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt

To resolve the conflict, follow these three steps:

  • Edit the file to resolve the conflict (nothing fancy needed here).
  • $ git add <filename>
  • $ git commit