Erdal TAŞKESEN Erdal TAŞKESEN

Posts related to Git

How to fix wrong Git Tag date

07 December 2018

You can add git tag to a previous commit using git tag TAG_NAME COMMIT_HASH, but it will ammend current date to that tag which can screw your repository by making out of chronological order. Don’t worry, You may fix this using the code below.

git tag -l | while read -r tag ; do COMMIT_HASH=$(git rev-list -1 $tag) && GIT_COMMITTER_DATE="$(git show $COMMIT_HASH --format=%aD | head -1)" git tag -a -f $tag -m"$(git show $COMMIT_HASH --format=%s | head -1)" $COMMIT_HASH ; done && git push --tags --force

How to change a commit timestamp

20 September 2018

You may need to change the DateTime of a commit in some situations. For example, some countries use daylight saving time period and because of it, some of the commits can have the wrong timestamp.

git commit --amend --date "Thu Feb 15 22:37:31 2018 +0300"

Ignoring the .gitignore file

23 March 2018

Today I have a small disagreement with GIT and git ignore rules. When you add a file to a GIT repository, it is tracked by GIT. Then adding it to .gitignore won’t make GIT forget about that file.

In this post, I will explain how to stop GIT from tracking a file that is already tracked.

Saving the local changes temporarily in Git

08 March 2018

Imagine that you’re working on a big feature in your app. Then you get a critical bug ticket that should be resolved immediately. You don’t want to commit the messy code. You just want to save your dirty working environment, do urgent things and go back it. For this, you can use git stash command.