First of all, I am new to Git. Using Git Bash, I created a feature branch 123-Feature-A using git branch 123-Feature-A, checked it out and then added some files through Visual Studio 2010. Git status showed the new files, I added them using git add . - since I have the VS2010 Git Source Control provider installed, I can see the icon changed to indicate that the file has been added.
When I want to switch branches I run something like git commit -a -m "added files" in the feature branch and then switch back to the master branch. When I am in the master branch, I see the files in VS2010, but the icon has a exclamation point and when I try to open it, VS tells me it does not exist - is there a setting in VS to hide files that I added in Brand-A, if I switch to Branch-B
It's been a while, but I think when I had this same issue I installed a git extension to VS.
Try http://www.codeproject.com/Articles/354101/Source-Code-Versioning-with-Git-in-Visual-Studio Or: http://gitscc.codeplex.com/
If you install one of these, make sure to use it consistently to manage git. That will keep VS up to date.
your workflow is totally fine from Git stand point but may be confusing for VS, assuming you have no Git support in it. Eclipse with git plugin detects this scenario just fine and if needed F5 (project refresh) resolves most of issues.
Just double check that you do have git support in your VS, i.e. that you can for example make git commits, switch branches etc. Otherwise, VS will be always confused in such scenarios, because of the way how git operates when branch is changed.
Related
I have a project already connected to visual studio team services, because it is already connected there is no option to connect to a new git repository.
Does anyone know how to send the source code to GitHub through visual studio when this is the case?
When I go to the file menu there is nothing saying "add to source control".
Or in the bottom right button, there is only a master button which has something about branches.
I don't understand why they make it so hard by redefining so many things like download to pull and upload to push.
Can someone tell me that answer as well?
It is easier to switch to command line and check if your local sources are themselves in a Git repo:
cd /path/to/local/project
git status
git remote -v
If those commands fails, that means your project is connected to visual studio team services through TFVC, and not Git, in which case, you need to create a local Git repo (which will co-exists with the TFVC one)
git init .
git add .
git commit -m "first commit"
Eve if the Git repo already existed, you can continue with:
git remote add github /url/empty/GitHub/repo
git push --mirror
When I build a project with Xcode, the default git location is fine. I'm able to initiate source control through Xcode like normal. But when I build sessions from other Apps, such as the Projucer, I can't use the custom git location, as it doesn't see all the files. I need to manually create the first git commit in the correct location with:
git init
git add .
git commit -m "First Commit"
After this, Xcode sees the git repo and as is able to take off from there, and I dont have to use command line after that.
My question is, is there a way to set the default location of git within Xcode? Avoiding commands? Also, are there any visual ways to gitignore files through Xcode? Thank you.
As illustrated in Setting up a git repository in XCode for a pre-existing project, you would still still those Git commands.
The "Git Create Project" of XCode 7 and 8 would still create a .git in the default location (<root of the project>/.git)
I am using Visual Studio 2012 along with Git Extensions. Everything had been working fine (as far as I could tell), but now when I make a change in one of my branches, it is showing up in my other branch. It is changes both branches at the same time....any ideas?
if you don't commit your change, it "travels" to another branch that you switch to. While you may have multiple branches, you only have 1 working directory. What I usually do is:
git stash -u
then switch branch, experiment in VS. Then when I'm ready to go back, I
git stash pop
and it returns to the changes I had.
A common workflow is
git stash -u
git checkout someotherbranch
# experiment
git checkout -
git stash pop
Using the command line is really good as you get history. Try going with just msysgit for a while and you'll see the advantages of history, piping, tab-completion, etc.
btw, git checkout - works just like cd -, allowing you to continually switch between 2 places. Very useful.
I'm sort of stumbling around with an issue with Xcode 4, and Git. I'm a one man shop with multiple macs, and had my project working with Git and Xcode4, (stored on a dropbox folder), so I could share that folder across my MBP and iMac with minimal interaction. So, it was late one night and I accidentally committed my xcode project file, and then I started getting issues with UserInterfaceState.xuserstate constantly updating... Later learned that .gitignore would have been good to have in place.
Back to the drawing board and I've been trying to take the new (old) project and enable git on it with the following:
$cd path/to/project
$git init
$git add .
$git commit -m "Initial commit of project"
This works fine, now I'm back in XCODE, and add the repository, which it recognizes in Organizer. One Issue is XCODE doesn't recognize that I've modified a file, and the majority of the "Source Control" menu items are disabled, Ex: "Commit"
I'm wondering if there are a recommended # of steps to:
1) Get Git running on a xcode project that wasn't set up this way initially
2) Steps to add the Gitignore file and when
Ultimately would like the "Source Control" menu items enabled again.
I'm obviously learning some Git SCM related items with xcode 4, and I appreciate your feedback!
Maybe this isn't the answer you want but I gave up on getting Xcode4 to play well with git and just started using the excellent (and free) SourceTree. It really made my life easier.
To add Git to the project
Go to the directory and in a terminal window
cat > .gitignore
build/*
*.pbxuser
*.perspectivev3
*.mode1v3
javascripts/phonegap.*.js
Type Ctrl+D to close the file.
Initialize the Git repository
git init
git add .
git commit -m
Add the repository in organizer. Use the full directory path.
Caveat - this still does not enable Source Control menu items. But you can use git from the command line.
See other related post: Using Git with an existing XCode project
There are three ways of setting up exclude files in git. Which is easiest depends on you. But, I find that when using git to share for myself amongst multiple machines, a global ignore file works best, and I can always add more specific excludes if you need to.
Essentially
Globally, by setting up a per user or per machine exclude file
Per repository - by setting up a .gitignore file in the repo
Per clone - by setting up the `.git/info/excludes file
I've got a my global exclude file on Github if you want to see an example, including Xcode4 specific exclusions.
I've been playing around with git at home and I really like the idea of local commits. Being able to commit smaller changes without spreading my potentially broken code to everyone is nice, as well as being able to revert smaller changes because of the more frequent commits.
I've been reading about the git-svn command, but I'm not sure I entirely understand how it works. We work on Visual Studio 2008 projects, and run VisualSVN which handles file renames, moves, and all that for us from within the IDE.
What I want to know is: Is it possible for me to commit to a local git repository but also commit to the remote SVN repository as well? I'd like to keep VisualSVN change tracking and committing from within the IDE, but also be able to use git to temporarily store changes. Are they likely to get in each other's way?
It works beautifully. go for it. Just don't check your .git folder into svn.
edit: erm, when I do it though, I don't bother with git-svn. I just treat the local working directory for svn as any other directory, and I tend not to care much about the previous SVN history.
I've used git-svn to keep "updating" from the remote repository, but haven't used it to commit to an svn repository, so I can't help you about that part.
What you do is simple, with all settings on default:
>git svn init <url......>
>git svn fetch
When you do that, it fetches it to a "remote" branch called "git-svn".
To merge it with your current branch:
>git merge git-svn
You may run into some issues if you're using git-svn after the fact. What I mean by that is: you already have checkout the project using svn, then you also created a git repository in your local working svn directory. Then you use git-svn on top of that.
Two issues I had to deal with:
Line endings. svn might convert line endings to windows, while git-svn will preserve them to unix style. So you might get tons of conflicts due to the line ending differences.
So to be sure, use a tool to convert line endings on all files to unix (or windows, depending on what line ending is used in the svn repo).
svn keyword expansion. e.g. $Id$
git-svn will not expand these keywords, while svn will. So you'll have conflicts there as well. Again, use a tool (or write a script) that converts all instances of $Id .......crap.....$ to just $Id$`