I am entirely new to Git, SourceTree, and everything about it. I am using SourceTree with Bitbucket but I need some help. As I know absolutely nothing about Git or SourceTree, I would like to learn how to use SourceTree to revert all the files in my Git repository to the state they were in when I made an earlier commit. Basically I want to roll back to an earlier commit so that I can access the files as they were at that point, but I want to be able to keep my existing commits so that I can roll forward as necessary. I also want to be able to make commits of the files based on the files from older commits. How can I do all of this?
Disclaimer: I'm a command line guy, so I haven't used SourceTree enough to tell you specifics, there.
As I read your question, all you are really wanting to do is view that version of the tree, not undo everyone's changes. This is simply a "checkout". Given SourceTree's GUI nature, I would expect this to be something like right-clicking on the commit you are interested in and choosing the checkout from a pop-up menu or something similar.
For reference, the command line version of doing that looks something like this:
cfuller@crf:~/src/atlassian/jira-bugfix [(atlassian_jira_6_3_8)]$ git log --oneline | head -5 68f19fa AUTOCOMMIT bump JIRA version from 6.3.8-SNAPSHOT to 6.3.8 514f45b NONE: Fix webdriver batches PT so it doesnt duplicate the definition of batch 06 7facb80 JDEV-30619: Updating variables for 6.3.8 stable release cut 27029ae Merge pull request #1810 in JIRA/jira from stable-issue/JDEV-30651-upgrade-dvcs-connector-2.1.24 to atlassian_jira_6_3_branch 76d9270 Merge pull request #1799 in JIRA/jira from stable-issue/SW-533-inline-component-bugfix to atlassian_jira_6_3_branch cfuller@crf:~/src/atlassian/jira-bugfix [(atlassian_jira_6_3_8)]$ git checkout 76d9270 Previous HEAD position was 68f19fa... AUTOCOMMIT bump JIRA version from 6.3.8-SNAPSHOT to 6.3.8 HEAD is now at 76d9270... Merge pull request #1799 in JIRA/jira from stable-issue/SW-533-inline-component-bugfix to atlassian_jira_6_3_branch cfuller@crf:~/src/atlassian/jira-bugfix [(76d9270...)]$
My working directory has now been set up exactly as things were at that commit. To get back, I just checkout the original position:
cfuller@crf:~/src/atlassian/jira-bugfix [(76d9270...)]$ git checkout HEAD@{1} Previous HEAD position was 76d9270... Merge pull request #1799 in JIRA/jira from stable-issue/SW-533-inline-component-bugfix to atlassian_jira_6_3_branch HEAD is now at 68f19fa... AUTOCOMMIT bump JIRA version from 6.3.8-SNAPSHOT to 6.3.8 cfuller@crf:~/src/atlassian/jira-bugfix [(atlassian_jira_6_3_8)]$
Thank you for your help. As I am new to Git, I am using SourceTree for now, but eventually I would like to transition to command line usage.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also, as someone who is new to Git, you should read the Git book. It won't take much time. You should focus on 1.1-1.3 and chapters 2 and 3. The examples there are all command line, but understanding the terminology will make the Sourcetree UI much more intuitive.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
You should explore more about the following commands
Documentation and tutorials available at
https://www.atlassian.com/git/tutorials/undoing-changes/git-revert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, but I am new to Git and want to learn how to use Git with a user interface (SourceTree) before using command line to do everything.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.