You have been away for a while, you come back and the team has made huge progress, you do a git status in your repo and you have uncommitted changes but have no clue when you were doing at the time!

Write your answer…

8 answers

If I cannot remember what I did, I usually

  1. $ git branch -l to see what I was working on
  2. use a diff against the last commit in my local repo and work on / commit with a useful message
  3. if I still dunno what I did $ git reset --hard && git pull
  4. work on

If you cannot remember what you did, your changes are probably not important anyway. If your team has even made "huge progress" after "you have been away for a while" while not needing your commit, your contribution was probably not necessary either or already implemented by someone else.

Never commit stuff you do not understand. Never commit untested changes. Ideally, implement review and CI processes for pushes and pull-requests. Also try out a sane git branching strategy, using feature branches, so you at least know what you were working on. I really like gitflow , but depending on your situation, there are other good strategies as well.

When writing a commit message, I usually use a verb as the first word followed by the content, for example

$ git commit -am "implement .abc file format for asset loader"
$ git commit -am "fix #123"
$ git commit -am "add package.json"
$ git commit -am "remove foo as a dependency"

Can do git stash instead of git reset though, in case you remember later.

Reply to this…

Hashnode is a friendly and inclusive dev community.
Come jump on the bandwagon!

  • 💬 Ask programming questions without being judged

  • 🧠 Stay in the loop and grow your knowledge

  • 🍕 More than 500K developers share programming wisdom here

  • ❤️ Support the growing dev community!

Create my profile

2 things ...

  1. you should never commit what you don't understand.
  2. you write in the commit message what the changes are.

there are different philosophies ... I write in present tense

#ticketNr <summary headline>
 - does blabla
 - change blub
 - add moo

as an example

#1337 implements new menu endpoints
 - adds role model and references
 - adds new backend for menu customization
 - changes parts of the user model
Show all replies

I too like to summarize things in bullet points on a commit after the summary headline. If anything, I rely on them for remembering smaller details about a commit that wouldn't be obvious via just the headline.

Reply to this…

If your company uses only sort of project management or ticketing system, you could leverage that. I use the GitFlow branching strategy. So when I start working on a new feature, I'll make a feature branch which I name with a ticket number. Example: features/BRB-247. When the branch is named in this way, you can refer back to the associated ticket to remind yourself what you were working on.

And hopefully you haven't changed ticketing systems in the interim :D

Reply to this…

That situation should ideally never arise in the first place. I strongly follow Atwood's recommenation of Commit Early, Commit Often.

if the code isn't checked into source control, it doesn't exist.

Reply to this…

I use IDE changelists which are named as [issue number] short description. This makes it easy to remember what the changes were for.

Reply to this…

Load more responses

The Author Card

cengkuru michael's photo

cengkuru michael

Full Stack Web Developer

Appreciations

299

Location

Kampala Uganda

Joined

Apr 9, 2016