Why does Visual Studio think I'm on a different branch than my terminal and VS Code - visual-studio-2019

I have a .NET 5 solution, using git for source control.
If I open it in Visual Studio 2019, the branch selector at the bottom right says foo
If I navigate to the root directory in a terminal window and check the current branch with git rev-parse --abbrev-ref HEAD, it says I'm on branch bar
If I open the root directory in VS Code, it also says I'm on branch bar
If I checkout another branch from my terminal like this: git checkout main, then both my terminal and VS Code say that my current branch is main, but VS2019 still says foo
What's going on?

Still not sure why this was happening, but deleting the .vs folder and restarting the solution/VS2019 seems to have fixed it.
Root Directory
- .git
- .gitignore
- README.md
- src
+ .vs // deleted this and restarted VS2019
+ MySolution.sln

Related

Git - Illegal characters in path git visual studio 2019

I'm working on Xamarin.Forms project and I'm in the master branch and I'm trying to check out another branch but I'm getting this error in VS 2019:
& I'm getting this error when using commands:
Notes:
This is my first time checking out this branch
I can check out other branches normally
The paths mentioned in the error don't exist.
I don't care about the ios application for this project, I focus on the Android one.
What should I do to fix this error and check out the branch successfully?
In command line, try and set a sparse checkout clone first, then open the IDE for your Xamarin project:
git clone --filter=blob:none --no-checkout https://github.com/remote/project
cd project
git sparse-checkout set /* !/.vs/JM?/xs/project-cache
git sparse-checkout init
# that sets git config core.sparseCheckoutCone true
git read-tree -mu HEAD
The idea is to ignore the content of .vs/JM?/xs/project-cache (assuming .vs is right under the root folder of the repository) on checkout (of any branch).

How can I un-nest a Git repository

I accidentally did a git.init on a parent folder of my app (Rails project). I didn't realise until a long way into my development when I now wish to deploy to Heroku.
My folder structure is ~/project/project/app with git initialised in ~/project/app.
Heroku states:
"Heroku apps expect the app directory structure at the root of the
repository. If your app is inside a subdirectory in your repository,
it won’t run when pushed to Heroku."
So, I'm trying to undo this, without much success.
I tried moving all the folders of my app up a level, so from project/ I did the following command:
mv project/* project/.* .
This seemed to move a copy of everything up a level, into my ~/project folder, however, in terms of Git, only the still nested files (in ~/project/project/) are the branch specific files (as tested by switching branches and looking at both sets of files in my text editor).
I copied the files when my git branch was specified as the master branch. Does this mean I've only copied the "master branch" files. This is where my knowledge of git is limited.
Any help much appreciated.
** note, i have a copy of my folder or can re-clone from github.
If you don't have a problem to re-publish your repo (git push --force, meaning you will change the history of commits, and other will have to fetch and reset their local branches), you can refer to "How can I move a directory in a Git repo for all commits?".
Use git filter-branch in order to affect all commits of all branches:
git filter-branch --tree-filter \
'test -d project/app && mv project/app . || echo "Nothing to do"' HEAD

How to delete all local and remote Git on Xcode 7 project

I'm working on an iOS Xcode project whose previous developer has configured and committed to local git and remote git using his account. Now I want to delete every source control existing on the project (local and remote) and recreate a new one. How can I make everything fresh so that I can commit and use the source control? (I don't have the previous developer account.)
in order to delete your local git you need to open your file system where your project is located and delete the .git folder. please notice that this folder is hidden by default so you will need to show hidden files and folders before doing it.
Delete of remote repository should be done on the server. If for example your are using github.com then you need to go to github.com and inside your repository go to settings tab and on the bottom you will see the Danger Zone there you can delete your remote repository.
The easiest way is to remove the invisible .git directory at the root level of the project. From there, you can recreate the repository and any remotes.
Be warned, this will delete all history for this project!
To remove all local and origin branch from XCode 8 follow these steps :
1. Source Controll / ProjectName/ Configure ProjectName.
2. In Configure ProjectName Window select Branches tab.
3. Select any branch name from local or origin.
4. Click on "-" icon on bottom left.
That branch will be removed from local machine.
And for removing branches from Github server you can delete repos from server.

Xcode change repositories

Maybe anyone knows a way how to change repositories.
I have to continue a project made by other company, and they have their svn repository in their server. I'v created my own git repository, yet the files keep commiting to the old svn. Deleting the first repository in organizer does not help at all, if i try to commit file, it recreates...
So how do I switch between old svn to my new git repository ?
close XCode, go into the terminal and delete all the .svn directories from the folder hierarchy, issue "git init ." in the root directory and now restart XCode.

TFS 2012 Unshelve to different branch -> An item with the same key has already been added

I need help resolving the following issue:
I am attempting to unshelve code from the source branch onto a target branch.
I am using the following:
VS2012 RC
TFS 2012
VS2012 x64 Cross Tools Command Prompt
When I use the command prompt to perform the unshelve operation, the following occurs:
Shelveset details dialog gets displayed with list of change files.
Click Unshelve button.
Observe command prompt output: "An item with the same key has already been added."
I have downloaded ServicePack1 for power tools.
However, I have failed to resolve this issue.
I had the same issue and fixed it when I re-shelved the changeset from the source branch but chose not to preserve pending changes locally. After this the migration of the new shelveset ran smoothly.
(I also made sure I'd followed the below steps collected from other answers on this site)
Use a workspace that encompasses both source and target branches
Run the command from the folder mapped to the source branch
Check for quotes around any paths containing spaces
Deleting the cache in C:\Users[USERNAME]\AppData\Local\Microsoft\Team Foundation\4.0\Cache and restarting Visual Studio
I had the same error when using Visual Studio 2013 and the following command:
> tfpt unshelve /migrate /source:"$/Root/Solution" /target:"$/Root/Branches/Solution" "The name of my shelveset"
> An item with the same key has already been added
Research
Here's what I tried to fix the issue:
Clearing the Cache as per Andrey's answer
Try running the command from the Source -> Branch and Branch -> Source
My workspace already encompassed both source and target branches
Solution
Open up your equivalent of the VS2013 x86 Native Tools Command Prompt.
Check you have Team Foundation Power Tools installed:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\tfpt
Ensure you have 0 Pending and Excluded changes.
I had some Excluded changes which were detected but not added and this is what caught me out. Excluded changes should look like this:
Note: No "Detected: XX (adds)" - should not be visible
When you run tf status, you should see something like the following.
Either 1 change(s) for the .tfignore file or 0 change(s). Anything else will upset the merge.
C:\tfs\Root\Solution>tf status
File name Change Local path
$/Root .tfignore edit C:\tfs\Root\Solution.tfignore
1 change(s)
Ensure you are running the tfpt command from the source Solution directory
You should be now be able to successfully merge a shelveset from one branch to another.
Note on .tfsignore:
If you have a lot of pending changes that you don't want to undo for whatever reason, then
a modification to the .tfignore file is ok.
If this is the only file that you have left with changes, it won't brake the merge.
.tfignore reference => stackoverflow - How to ignore files/directories in tfs?
Try to undo all changes on Source and Target branch and then try again...
Try to delete all the files in the following folder and restart VS2012 (Source):
C:\Users[USERNAME]\AppData\Local\Microsoft\Team Foundation\4.0\Cache

Resources