User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
project_management:git [2010/06/21 16:35]
project_management:git [2020/01/30 12:53]
aorth removed
Line 51: Line 51:
 <code>$ cd beca_lims_portal <code>$ cd beca_lims_portal
 $ git log</code> $ git log</code>
 ====== Tagging ====== ====== Tagging ======
-See uses two main types of tagslightweight and annotatedA lightweight tag is very much like a branch that doesn’t change — it’s just a pointer to a specific commit. Annotated tags, however, are stored as full objects in the Git database. They’re checksummed; contain the tagger name, e-mail, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). It’s generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don’t want to keep the other information, lightweight tags are available too.
-<note>Normally, you want to at least pass the -a option to create an unsigned tag+<note>Without arguments, ''git tag'' creates a "lightweight" tag that is basically a branch that never moves. Normally, you want to at least pass the ''-a'' option to create an unsigned tag.</note> 
 +  * 
 +  *
 ===== Tagging the current version ===== ===== Tagging the current version =====
 <code>git tag -a v0.2</code> <code>git tag -a v0.2</code>
Line 73: Line 75:
 Push all tags which are not already on the remote origin: Push all tags which are not already on the remote origin:
 <code>$ git push origin --tags</code> <code>$ git push origin --tags</code>
 +==== Reverting a file to a particular revision ====
 +If you want to revert a file in the current working revision to a past revision
 +<code>$git checkout <commit_hash> filename</code>
 +====== Tips ======
 +===== Edit a commit =====
 +To edit a commit (like fixing a spelling or logic mistake):
 +  - Look at ''git log'' and copy the first 5 or so characters from the ID of the commit you want to edit onto your clipboard.
 +  - Start the interactive rebase process, pasting in the characters from the ID: git rebase --interactive ID
 +  - Your editor will come up with several lines like ''pick d3adb33 Commit message'', one line for each commit since the older one.
 +  - Change the word "pick" to "edit" in front of the commit you want to change.
 +  - Save and quit.
 +  - Edit your project files to make the correction, then run git commit --all --amend
 +  - After you’ve committed the fixed version, do git rebase --continue
 +===== Change the last commit's author =====
 +Sometimes you commit something without realizing you haven't properly configured your //~/.gitconfig// Simple amend the last commit:
 +<code>$ git log -n1
 +commit 85f761ec52e4be90acd2dc7c9f5842e36ad7d783
 +Author: Alan Orth <>
 +Date:   Sun Nov 21 05:07:48 2010 -0500
 +    Initial Import of DSpace 1.6.2
 +$ git commit --amend --author 'Alan Orth <>'
 +... vim/nano will pop up, save the commit
 +$ git log -n1
 +commit 85f761ec52e4be90acd2dc7c9f5842e36ad7d783
 +Author: Alan Orth <>
 +Date:   Sun Nov 21 05:07:48 2010 -0500
 +    Initial Import of DSpace 1.6.2</code>
 +===== Assume file unchanged =====
 +Certain files, like database configuration files, need to be tracked but you don't want to push changes to the remote repo.  This is different than using a ''.gitignore'' file, as //those files are not tracked in the repository// This allows you to have a generic database config in your repository without telling everyone your database password!
 +<code>$ git update-index --assume-unchanged common/config</code>
 +===== Assume file changed =====
 +The opposite of the above:
 +<code>$ git update-index --no-assume-unchanged common/config</code>
 ====== Configuration ====== ====== Configuration ======
Line 98: Line 143:
     changed = green     changed = green
     untracked = cyan</file>     untracked = cyan</file>
 + ==== Check the current git configurations ====
 +<file>git config -l</file>