Unable to create a snapshot in XCode 4.5.1 after update the ~/.gitconfig option [push.default] to "simple" - xcode

I was able to create a snapshot for my project in XCode 4.5.1. But now the same project just keeps telling me that:
Unable to create a snapshot
error: Malformed value for push.default: simple
error: Must be one of nothing, matching, tracking or current.
fatal: bad config file line 21 in /Users/oppih/.gitconfig
I remember that when I pushed another project onto github ealier today, I was prompted with this warning:
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
So I googled it and find this question not so long ago: 13148066, and got it settled, I use git config --global push.default simple since "This is a more intuitive behavior, which is why the default is getting changed to this."
I think my problem with XCode must have a connection with this git option update.
Back to XCode, I did not choose to setup a git repo in my XCode project, but used the snapshot as a way to backup my code. I think there's some trick with git in XCode's snapshot, I cannot figure it out. Now I wonder if anyone can tell me how to re-enable the snapshot in XCode (while not to change the .gitconfig [push.default] option)?

I managed to solve my own problem. See it in Question 10449374 for the related details.
The main problem in this case is that: Xcode just install (along with the Command Line Tools) its own version of git in /Applications/Xcode.app/Contents/Developer/usr/bin .
And somehow, Xcode also hard coded it would use its own version of tools (such as git). And (I don't know why) Xcode's "snapshot" feature has some integration with git.
So when I:
installed a new version of git via homebrew,
update the new push.default option in ~/.gitconfig ,
want to create a snapshot in an Xcode project
Then I will encounter the problem I described above.
Here's my solution:
change into the Xcode directory:
cd /Applications/Xcode.app/Contents/Developer/usr/bin
rename the Xcode's git like this:
sudo mv ./git ./git-xcode-usr-bin
link my own git which is installed through homebrew:
sudo ln -s /usr/local/bin/git ./git
And I did the same thing with /usr/bin/git
sudo mv /usr/bin/git /usr/bin/git-xcode-usr-bin
sudo ln -s /usr/local/bin/git /usr/bin/git
This will acctually link /usr/local/Cellar/git/1.8.0/bin/git (because I'm use git 1.8.0 at the present)
It's a little tricky, and I have to update the link if I upgrade the homebrewed git in the future. And it really works fine with Xcode's snapshot and the new push.default option.

Well, you may try specifying another .gitconfig file for Xcode by method provided in this answer: How can I specify custom global gitconfig path?.
For example, after created ~/.xcode_home as the new $HOME for Xcode app, you can use the following shell script to launch Xcode:
HOME=$HOME/.xcode_home open "$(xcode-select --print-path)/../.."
It is not quite user friendly though… Any way, you may want to check this: Setting environment variables in OS X?. But be warned, overwriting $HOME globally might not be a good idea.

Related

How to upgrade Git on Windows to the latest version

I just upgraded to Git 1.8.0.1 for Windows, from my previous version 1.7.9.mysysgit.0. I downloaded the new version from the Git site and installed through the normal Git installer EXE.
That said, when I fire up my terminal window, it still is showing that I am running Git version 1.7.9.mysysgit.0. When I type git --version from my prompt, the same thing.
I found this article on a similar issue with Git on Mac OS X, which leads me to believe that it has something to do with a faulty PATH, but I'm still pretty new at all this (five months self-taught), so I'm at a loss in how to translate this to Windows.
This problem arose when I began a new Ruby on Rails project and tried to push it up to Git. I added the remote:
git remote add origin git#github.com:brianscottk/blog.git
then:
git push -u origin master
I received the following error message:
fatal: https://github.com refs not found: did you run git update-server-info on the server?
Googling that error led me to this article, which prompted me to upgrade, and here I am.
Since Git 2.16.1(2) you can use
C:\> git update-git-for-windows
In version between 2.14.2 and 2.16.1, the command was
C:\> git update
(It was later renamed to avoid confusion with updating the local repository, e.g. like svn update does it.)
That command does not exist in Git 2.13 and before.
If this errors with "is not a git command" then either you don't actually have Git for Windows, or your version is very old.
In which case, simply get the latest installer from https://git-scm.com/download (check whether you want 32- or 64-bit) and run it to upgrade.
If you already have the latest version it does nothing, in which case you can manually run the installer to reinstall.
C:\> git update-git-for-windows
Git for Windows 2.17.0.windows.1 (64bit)
Up to date
First, check your Git version by using this command
git version
Then follow the case according to your Git version
Three cases:
If your Git version is 2.14.1 or earlier:
Uninstall Git, download the latest Git, and install it again.
And versions between 2.14.2 and 2.16.1:
Use command git update
If the version is equal to or greater than Git 2.16.1(2):
Use command git update-git-for-windows
Git Bash
Note, if you are instead looking to find out what version of Git Bash you are running, or want to see if you need to update Git Bash, it is part of Git for Windows.
So your Git Bash version is:
git --version
git version 2.23.0.windows.1
Note that it is technically different from Bash. On my same machine when I run:
echo $BASH_VERSION
4.4.23(1)-release
Git for Windows installer
To update to the latest version of Git and Git Bash, you can download and install the latest version of Git for Windows. As per this FAQ, settings/customizations should be preserved if they were installed in the appropriate configuration folders.
Note: Their installer is actually intelligently designed to do the right thing (though it doesn't tell you upfront that it defaults to your prior settings automatically!).
If you are doing an update, then every screen on the installer is pre-marked with the settings from your current (soon to be previous) install.
It is not showing you generic default settings. You do not need to look any of them up, or fear for breaking your carefully honed setup. Just leave everything as is, to retain your previous choices.
In fact, they made it even easier (if only it was clear that they did so).
There is a checkbox at the bottom [] Show only new settings (I don't remember the exact wording). Since nothing on the first screen changes when you mark the box, it is not exactly obvious what it is for. If you mark the box, then all of your current settings will be retained, and it will skip showing those (subsequent) settings screens to you. Only screens with newly introduced settings will be shown.
git update-git-for-windows
Alternatively, as others have noted, you can also update Git Bash and Git (by definition, both are always updated at the same time) from the Git Bash command line, via:
git update-git-for-windows
If you type git update, Git kindly reminds you that the command has been updated to git update-git-for-windows:
Warning! git update has been deprecated;
Please use git update-git-for-windows instead.
Git for Windows 2.26.0.windows.1 (64bit)
Up to date
Just give the following command with your command prompt.
git update-git-for-windows
This will ask you a confirmation as follows. Press Y to proceed.
Once the files are downloaded, continue with the normal installation procedures. You can check the Git version after finishing installation with the following command:
git version
For me, the result was as follows.
Update (26 September 2016): It is no longer needed to uninstall your previous version of Git to upgraded it to the latest; the installer package found at Git Windows download site takes care of all. Just follow the prompts.
For additional information, follow instructions at installing and upgrading Git.
If you just type
git update-git-for-windows
If you are having issues with it, run Bash as administrator or add the 'git.exe' path to the "allowed apps through controlled folder access".
If you have already installed Git, you can update Git with the command
git update-git-for-windows
to know the current version, use:
git --version
You can run these commands in the cmd prompt.
Check version: git --version
If your Git version is 2.27.0.windows.1 or earlier
If the version is equal to or greater than Git 2.27.0.windows.1
Use command git update-git-for-windows
If you want to see a video tutorial click here.
Just run:
git update-git-for-windows
Use git update-git-for-windows as in this session:
PS Z:\MERN-STACK-ECOMMERCE-PROJECT> git --version
git version 2.31.0.windows.1
PS Z:\MERN-STACK-ECOMMERCE-PROJECT> git update-git-for-windows
Git for Windows 2.31.0.windows.1 (64bit)
Update 2.33.1.windows.1 is available
Download and install Git for Windows 2.33.1 [N/y]? y
############################################################################################################ 100.0%-
############################################################################################################ 100.0%
PS Z:\MERN-STACK-ECOMMERCE-PROJECT> git --version
git version 2.33.1.windows.1
PS Z:\MERN-STACK-ECOMMERCE-PROJECT>
Using the command "where git" find out how command prompt picks up the version. Once you have the path, you can go ahead and uninstall / delete previous version completely. Then if you install and make sure the new installed location is in the path, it should just work fine.
Using git-friendly tools like cmder will make your life much easier. You don't really have to use dual boot or cygwin anymore since the support for git in windows is already top-notch now. (Git for windows installs msysgit which includes all necessary unix tools from MinGW. MinGW has been there for a while and is pretty stable. If you want you can install the full version of msysgit rather than Git for Windows. msysgit is available on Git for windows page at the bottom.)
You can use,
git update
Or if you are on a Windows machine, you can run the command below,
git update-git-for-windows
Based on Simon's answer, I first uninstalled the new version of Git. I then re-installed the new version of Git into the same directory as the old version, C:/RailsInstaller/Git, instead of the default directory C:/Git.
Now my Ruby on Rails terminal window shows that I am running the new Git version 1.8.0.
If you look at the most recent update on Git's website in the "git via git" section you will see an option to update your older version.
Here is the command that git has on their site:
git clone https://github.com/git/git
It worked for my version of git which was a 2.13.0.windows.1.
To check out your PATH variable, act as follows:
From the Desktop, right-click My Computer and click Properties.
Click the Advanced System Settings link in the left column.
In the System Properties window click the Environment Variables button.
Once there, scroll to get the Path row. You'll get a long string of paths (e.g., C:\windows\bin;C:\program files\git, etc.).
Find the line or lines where git is referenced. Then, make sure this path point to your Git 1.8.x installation. If not, delete it and add the real path to the newest Git version. At the end, you should only have one path in the string linking to Git.
I don't think your problem is related to Windows' global PATH environment variable, as remote is specific to repositories.
I recommend you to use Git under Cygwin. Git could work under Windows command line, but there may be some weird problems hard to figure out. Under Cygwin it's more nature and has fewer errors.
All you need is to type bash in Window CMD, and then start to use the Unix tools and commands. You can use a shortcut to load bash; it's as easy as use normal Windows CMD.
The same is true for Ruby on Rails and Ruby. I used RailsInstaller before, but I found using Cygwin to install Rails is more stable.
Finally, I'll suggest to install Ubuntu dual boot if you have time (about a month to get familiar with it). Windows is not very friendly to every Unix tools ultimately. You'll find all pain stopped.
On my Windows 10, > git update-git-for-windows refused to work with curl issues. Only the below command worked.
winget install --id Git.Git -e --source winget

Git hanging after installing osx credential helper

I'm having the same problem as this thread: Git hangs indefinitely - broke with osx credential helper I think
Basically -- had been running git without problems, then installed the credential-osxkeychain and git began hanging indefinitely after any command. e.g., running git init results in a hanging prompt and any input creates an error: bad input
I tried following the advice to delete git from usr/bin/git but now it doesn't recognize anything. I tried reinstalling git but now it doesn't seem to recognize it.
I ran which git and it returns: /usr/local/git/bin/git
I'm somewhat new at this and don't have the balls to just start running sudo commands and moving things around in the /usr/bin directory.
Any ideas what I can do to fix this?
I had the same problem and fixed it thusly:
uninstall git via the uninstall.sh that comes with the install
reinstall git via the installer
run which git and cd to the folder containing git (eg. cd /usr/local/git/bin/)
run curl -O http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain
run chmod u+x git-credential-osxkeychain
run git config --global credential.helper osxkeychain
Fixed.
Still not totally sure what I actually did to fix this problem, but resetting the terminal ended up getting it to work.
I had the same problem.
I didnt have git 1.7.10 or later installed. Messed everything up.
To fix, I had to delete git and install a newer version.
I used homebrew to install, after deleting.
is working again.
To fix this I reinstalled git from http://git-scm.com/download/mac
and then added /usr/local/git/bin to the top of the file /etc/paths

Installing Git separately from Github for Mac

I've installed Github for Mac.
I've realised that I need to get to the command line to do some stuff.
There is an option in Guthub for Mac to install a command line. All this seems to do is create an alias called Github in /usr/local/bin that points back to the Github for Mac application.
Double clicking it opens a terminal window and then Github for Mac.
Any ideas how to get Git to work in a command line?
Its a relatively clean version of Lion OS X
Git is included in the command line tools package provided by Apple that can be downloaded at https://developer.apple.com/downloads/index.action
It is also included with Xcode, which can be downloaded from either the Mac App Store or from the above link.
Assuming you'd rather not install either of these you can also obtain Git by downloading it from http://git-scm.com/downloads
Hope that helps.
https://help.github.com/articles/set-up-git#platform-mac
Should walk you though installing it.
I highly recommend installing Homebrew, which does a great job of keeping up with the latest git releases.
Once Homebrew is installed, it's as simple as:
brew install git
Note that, from May 2013, you now have with "GitHub for Mac" both:
the GUI
the CLI (Command-Line Interface)
See the blog post "Installing Git from GitHub for Mac"
you can now easily install Git for use on the command line, without needing to download any separate packages.
Even the git updates are taken care for you:
And whenever we update the version of Git included with GitHub for Mac, you'll get the changes automatically – no work required on your part!
you may notice some changes to the Preferences window.
On the newly renamed "Advanced" tab, simply click "Install Command Line Tools".
You'll be prompted for an administrator password so that Git can be installed into /usr/local/bin, and then you should very shortly see that it succeeded:
GitHub app create many links in /usr/local.
Use this command to find all link files from GitHub.
ls -l $(find /usr/local -type l) | grep GitHub.app | awk '{ print $9}'
then rm them.
PS: GitHub also created some directories that cause error when run brew link git,
e.g. /usr/local/share/git-core, /usr/local/lib/perl5/site_perl.
You should remove them carefully.

Install Git separately from Xcode

Firstly apologies if this is a really simple question but Git is absolutely brand new to me. Basically I've been dabbling with a bit of iOS development for a little while and now have a project idea that I want to start working on and for the first time I'm planning on putting this into source control.
Now I know Xcode 4 has some Git integration but I've spotted a couple of posts that suggest the integration isn't that great and it's better to do it the command line way.
So, I've been following instructions here http://git-scm.com/book/en/Getting-Started-Installing-Git and I've downloaded version 1.7.10.3 for Mac and ran the install.
However when I run git --version I get version 1.7.4.4 which is the version that was installed with Xcode I assume?
My question is, how do I make use of my new version 1.7.10.3? The plan is to learn to use Git via command tools and set up a central repository on a server I have at home, then have local copies on my laptop.
As I say I'm really new to this, so a quick step by step idiots guide would be helpful. I have searched and tried to find details here and on google but other than the suggestion to use Git outside of Xcode I've not found out exactly how to do it.
Any advice, or links to a decent tutorial that covers this would be very much appreciated.
Update:
I've changed the path to the new path in .bash_profile (/usr/local/git/bin) and now get git version 1.7.7.5 (Apple Git-26). This still appears to be the wrong version (although this could be me being dense). I downloaded the installer for OSX from the above link. Should I be doing something else. I want to play around with the command line tools so I can get a proper understanding
Update 2:
I'm now also trying MacPorts as recommended in the article. This seems to be downloading a lot more than just Git though
Xcode installs git in /Applications/Xcode.app/... but if you run 'Install Command Tools' then git gets installed also in /usr/bin/git. Xcode uses its private version in Xcode.app. If you installed git in /usr/local/git/bin then you need to include that directory in your PATH. You should have a .bashrc file (or equivalent for whatever shell you are using). Add
PATH=/usr/local/git/bin:$PATH # your shell might use different syntax.
to that file 'rc' file.
Also, note that Xcode would allow you to accomplish your goal of setting up a remote at home while maintaining a local copy on your laptop. Go to the Xcode 'organizer' and click 'repositories'. There you will find all your machine's Git repositories. Choose one, select the 'remotes' folder and then '+' to add your home remote. I use Xcode this way.
Credits goes to #GoZoner for the answer. I'm just summing up everything.
Download official git installer from : http://git-scm.com/download/mac
Install and add its directory to your path :
echo "PATH=/usr/local/git/bin:\$PATH" >> ~/.bash_profile
source ~/.bash_profile
The best way is:
step 1:
Install homebrew on your mac this is the official website Homebrew homepage
From a Terminal prompt:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
step 2:
From a terminal prompt
brew install git

override git from Xcode with homebrew version

I've installed XCode and therefore git is there as well. Since i want to have a newer version of git I installed using homebrew.
But the homebrew version of git is never called since my PATH looks like this
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
which means the /usr/bin/git is allways called before /usr/local/bin/git.
Is there a way to change that without changing the PATH?
Xcode is actually using the GIT that is stored in /Applications/Xcode.app/Contents/Developer/usr/bin. The same version of GIT gets installed in /usr/bin when you installed the command line tools as part of Xcode installation. So, you won't be able to change what Xcode is using (unless you are willing to muck with the contents of the Xcode package). If, from a terminal application, you want to use the homebrew-installed GIT then you have two options:
Reference GIT with the full path as /usr/local/bin/git ... For this case you can create an alias like alias mgit=/usr/local/bin/git and then use mgit ... from the terminal
Change the path as PATH=/usr/local/bin:$PATH either in your .bashrc or .zshrc if you use zsh file (or each time you start a terminal at the command line).
Since Xcode hard coded its own version of git which is installed on /Applications/Xcode.app/Contents/Developer/usr/bin/git, I managed to use this work around trick:
change into the Xcode directory:
cd /Applications/Xcode.app/Contents/Developer/usr/bin
rename the Xcode's git like this:
sudo mv ./git ./git-xcode-usr-bin
link my own git which is installed through homebrew:
sudo ln -s /usr/local/bin/git ./git
And I did the same thing with /usr/bin/git
This will acctually link /usr/local/Cellar/git/1.8.0/bin/git (because I'm use git 1.8.0 at the present)
Certainly this may cause some other problems, such as when I upgrade the homebrew's verion git in the future, it would not work for me :( and I have to make a new link then.
I do it like this because I want to solve my own problem here 13177203. And after search StackOverFlow for a long time, I finally got this solution.
If you are using fish shell instead of bash, you can point to your preferred git binary by adding the following to ~/.config/fish/config.fish.
function git
/usr/local/bin/git $argv;
end

Resources