Do you ever find yourself wondering things like: ‘How did my project look a few months ago?’ ‘How did my website look last spring?’
Sometimes, reviewing past versions of your code can be the best way to move your project forward. Thankfully, Git makes this possible, and GitKraken makes it easy.
Hop into our Git time machine, and we’ll go back in time together!
Identify your destination
First, you have to ask yourself: ‘How far do I need to go back?’. Then, with your date range in mind, open your repo in GitKraken, and scan your graph for the closest commit to the target date.
If you’re unsure where to locate the date, select a commit and review the date stamp on the right side.
If you’re working with a beastly repo that has more than 2,000 commits, you might need to solo or hide branches to go back further in time.
Trust, but verify
Once you select a commit, GitKraken will present the list of modified files in the right panel. However, if you click the View all files option, you will get your entire project tree view instead.
Click on a file to open the diff on the left-hand side. This should help you find what you’re looking for. 🎉
Get to work
Reviewing a file’s diff from tree view might be enough if you just need to copy and paste the code. However, say you need to run a local version of your website or perhaps you wish to build off from this commit. This is where creating a new branch will be key.
Right-click on the commit, and select Create branch here.
Now you can check out the branch, and your repo will change to match the state of the files at the point in time you traveled back to.
Other time travel options
Ah yes, the Fuzzy Finder. If you pull up the Fuzzy Finder using Command + P for Mac or Ctrl + P on Windows and Linux, you can type ‘History,’ and search GitKraken for the name of the file.
Select the file, and you’ll jump to that file’s entire history. The File View option is available for quick copy/pasting of what you need.
How is this even possible?!
Git tracks your project changes, and when you branch off a commit in your history, you are telling Git to apply a specific subset of changes. This makes it easy to travel through your project’s history, especially with GitKraken.
Stay on the cutting edge of software development by getting innovative tips, trends and stories delivered to your inbox every month!