Git - Commit

> Code - (Programming|Computer) Language > Code Versioning > Git

1 - About

commit in git

commit

Advertising

3 - Management

3.1 - Description

git commit -m "My Commit"

3.2 - Date

List:

  • GIT_AUTHOR_DATE
  • GIT_COMMITTER_DATE
# Give a date to the commit
git commit --date='Wed Feb 16 14:00 2037 +0100'
git commit --date='2005-04-07T22:13:13' # Iso
 
# Change the date of a previous commit
# The -C HEAD is just to bypass editing the commit message
git commit --amend --date='Wed Feb 16 14:00 2037 +0100' -C HEAD

See How can I tweak the date of a commit in the repo?

3.3 - List

Git - Log (Commit History)

git log --format=fuller
git log --pretty=oneline

3.4 - Undo

3.4.1 - Soft

Undo the last commit without deleting the changed files - Reset

# --soft is the default
git reset --soft HEAD~
Advertising

3.4.2 - Hard

If you accidentally commit on master, it's not hard to fix things up. Assuming you've just made an errant commit on master:

  • “Backs up” your commit, creating a topic branch
git branch myNewTopicBranch
 
  • Reset your master branch to the same state as upstream/master
git reset --hard upstream/master

3.5 - Delete

If you want to your working directory back to the status of upstream, see working directory purge

3.6 - Diff

3.6.1 - Command line

  • commits that branch-X has but master doesn't
git log master..branch-X

Options:

  • –oneline
  • –stat will show the files
Advertising

3.6.2 - DiffTool

Git - difftool

git difftool -y origin/master..origin/develop

3.7 - Checkout

git checkout commit_hash
git checkout 56a4e5c08

You are then in a detached head state.

4 - Documentation / Reference

code/version/git/commit.txt · Last modified: 2019/01/25 11:40 by gerardnico