How to transfer a file to the past?

Yesterday I made changes to the project file, but forgot to commit and click it on github. I do not want my deposit band to break after 51 days. So I would like to push this fix yesterday so that my streak continues ... Is this possible?

Thank you in advance!

+1
source share
2 answers

I have a script in my path called git-rcd that changes GIT_COMMITTER_DATE and GIT_AUTHOR_DATE any commit you want (and not just the last one)

 #!/bin/bash # commit # date YYYY-mm-dd HH:MM:SS commit="$1" datecal="$2" temp_branch="temp-rebasing-branch" current_branch="$(git rev-parse --abbrev-ref HEAD)" date_timestamp=$(date -d "$datecal" +%s) date_r=$(date -R -d "$datecal") echo "datecal=$datecal => date_timestamp=$date_timestamp date_r=$date_r" if [[ -z "$commit" ]]; then exit 0 fi git checkout -b "$temp_branch" "$commit" GIT_COMMITTER_DATE="$date_timestamp" GIT_AUTHOR_DATE="$date_timestamp" git commit --amend --no-edit --date "$date_r" git checkout "$current_branch" git rebase --autostash --committer-date-is-author-date "$commit" --onto "$temp_branch" git branch -d "$temp_branch" 

What allows me is to take the last commit I just made and type:

 git rcd @ '1 day ago' 

And presto! My last commit was made yesterday.

It changes any commit you want:

 git rcd @~2 '1 day ago' 

This will only change HEAD~2 (not HEAD~ or HEAD )

The script works even on Windows.

Once the change is done, click (or git push --force if you clicked earlier with the wrong date). And your strip is saved.

+2
source

Yesterday I made changes to the project file, but forgot to commit and click it on github

As far as I know, GitHub contribution charts rely on commit dates, not datetime. FWIW, there are even tools abusing it to use the contribution graph as a drawing board (see This google search ) ..

So the easy way is

  • Commit locally now

  • Then rewrite your last commit to change the date of authorship (choose the time and time zone you want), with something like git commit --amend --date="Wed Jul 12 14:17 2014 +0900"

  • Click

+1
source

Source: https://habr.com/ru/post/950784/


All Articles