Download SourceTree for Mac for Mac to simplify your interaction with your Git and Mercurial repositories so you can focus on coding. Brew Install My Dev Environment for macOS High Sierra - Slack, Docker, iTerm, IntelliJ, Google, SourceTree, Spotify, etc. brew-install-mac-dev-environment.sh.

Question or issue on macOS:

I’m new to the Git environment, and I’m using BitBucket with SourceTree on Mac. All I want to do now is to discard the changes since last commit. How should I do this? I haven’t found anything like “discard changes”, and directly pulling from the last commit doesn’t seem to work. Solutions done with either the GUI or command line will be good. Thank you.

How to solve this problem?

Solution no. 1:

I like to use

This stores all uncommitted changes in the stash. If you want to discard these changes later just git stash drop (or git stash pop to restore them).

Though this is technically not the “proper” way to discard changes (as other answers and comments have pointed out).

SourceTree: On the top bar click on icon ‘Stash’, type its name and create. Then in left vertical menu you can “show” all Stash and delete in right-click menu. There is probably no other way in ST to discard all files at once.

Solution no. 2:

On SourceTree for Mac, right click the files you want to discard (in the Files in the working tree list), and choose Reset.

On SourceTree for Windows, right click the files you want to discard (in the Working Copy Changes list), and choose Discard.

On git, you’d simply do:

git reset --hard to discard changes made to versioned files;

git clean -xdf to erase new (untracked) files, including ignored ones (the x option). d is to also remove untracked directories and f to force.

Solution no. 3:

On the unstaged file, click on the three dots on the right side. Once you click it, a popover menu will appear where you can then Discard file.

High

Solution no. 4:

Ok I just noticed that my question was already answered in the question title.

To unstage files use

And to undo the changes to a file

If you have a batch of files inside a folder you can undo the whole folder

Note that all these commands are already displayed when you git status

Here I created a dummy repo and listed all 3 possibilities

Solution no. 5:

Sourcetree For High Sierra Windows

From sourcetree gui click on working directoy, right-click the file(s) that you want to discard, then click on Discard

Solution no. 6:

Do as follow,

  • Click on commit
  • Select all by pressing CMD+A that you want to delete or discard
  • Right click on the selected uncommitted files that you want to delete
  • Select Remove from the drop-down list

Solution no. 7:

Ok so in Windows sourcetree that is simple, on macOS I looked as well for a while..

Click Command + Shift + R while in source tree a hidden popup will be shown that will let you discard individual files OR ALL! Why is this hidden? We will never know.. but it works]1

For

Hope this helps!

Question or issue on macOS:

I’m using OSX and want get a svn repo into a local git repo using sourcetree.

When I add a bookmark using sourcetree using SVN URL, thus sourcetree knows it’s a SVN url, but when I click the clone button, it reports an error like following:

I don’t how to get it through. Can anyone give me a pointer on how to do this?

How to solve this problem?

Solution no. 1:

Sourcetree

I hit this missing SVN/Core.pm issue recently with el capitain.

Fix I used was from Paul Schreiber’s blog :

Commenters below, say this worked on sierra and high sierra too.

Solution no. 2:

Or, if you don’t have Xcode, just CommandLineTools (this is on ElCapitan 10.11.6):

If you previously linked some older version or just made a mistake so it gives you: File exists, then you should first do

for whichever file was reported as already existent, of course.

Sierra

EDIT Dir doesn’t exist: (suggested by @rogeriopradoj)

EDIT Sierra:
After upgrading to Sierra I lost CommandLineTools, so I just had to reinstall it and everything was back to normal.
This will prompt you to install just the CommandLineTools, not the whole XCode.

xcode-select --install

Hope this helps someone 🙂

Solution no. 3:

In my case, it is because different versioned perl was installed by brew as dependency of some formula, and override the system’s default version.

So the resolution for me is to relieve the overridden as described following.

when type which perl and perl -v, I find it not the system default version:

which should be v5.18.2 according to the git svn error messages.

I guess it is because the different versioned perl was installed by brew as dependency of some formula, and override the system default version.

Sourcetree For High Sierra Os

To prove it, try to move /usr/bin before /usr/local/bin in $PATH, then perl was fallback to the system’s default version:

and perl -V list the @INC just satisfy the Can't locate SVN/Core.pm in @INC requirements:

type git svn and everything works well!

Solution no. 4:

Plus to the highest answer,
If you are using souceTree, simply paste command line may not work immediately.
In that case, you may need to check git used in your sourceTree, which should be set as System git.

Solution no. 5:

Xcode 11.4 no longer includes SVN/Core.pm in its Perl bindings!

Sourcetree For High Sierra Free

If you’ve never installed the commandline tools and Xcode 11.4 is the first version you’ve run you will see this issue. Running xcode-select --install returns error: command line tools are already installed, use “Software Update” to install updates, which is accurate but non-obvious that your installed commandline tools differ from what you would get if installed outside of Xcode 11.4. The solution is to first remove these, then install the commandline tools using xcode-select.

Solution no. 6:

Thanks Marko, I did find that on ElCapitan 10.11.3 I had to symlink to a different area. Not sure why, but it works.

Solution no. 7:

I got the same issue on Macos Mojave 10.14.1. Because I used the built-in version of git, and it’s too lower(2.19.0). I fixed it by upgrade git to the latest version(2.21.0), and I found 2.19.1 also has no this issue.

Solution no. 8:

Sourcetree For High Sierra

The solution for me was to delete the password entry in the OSX key ring app, and have git svn re-create it. My key entry has been created earlier (by svn I suppose), and it seems that git cannot use this key entry (nor fix it nor add a second one).

The long story: I noticed that when unsing “system git” in SourceTree, there seemed to be a problem storing the credentials. When I entered the same git command (that SourceTree is issuing) on the command-line, git kept prompting me for my password each time.

Sourcetree For High Sierra Download

Then I found https://stackoverflow.com/a/39800112/580672

If you are interested, my setup was:

  • No Xcode, only Command-Line tools (so I adapted the paths as mentioned in a post above ( https://paulschreiber.com/blog/2015/11/09/fixing-git-svn-on-os-x-el-capitan/comment-page-1/#comment-437843 )
  • Homebrew has svn and perl installed

I had tried with no success:

  • “embedded git” (yields the @INC error)
  • “system git” (different error: “Username: Use of uninitialized value $ret in chomp at /usr/local/Cellar/git/2.21.0/share/perl5/Git.pm line 596.”)
  • put usr/bin in front of my PATH as suggested above
  • force-uninstalled perl in homebrew

All without success. The solution was system git and the key entry, as stated above.

Solution no. 9:

I’ve found that the best solution is to expand the list of directories in @INC using an export

Referenced from: https://perlmaven.com/how-to-change-inc-to-find-perl-modules-in-non-standard-locations

Solution no. 10:

Manage to fix the same issue by changing the first line in /usr/local/Cellar/git/2.29.2/libexec/git-core/git-svn
to
#!/usr/local/bin/perl

Hope this helps!