August 4, 2023 at 9:37 am
Hi all
Warning - long post alert.....
We're just getting into DevOps and want to use Visual Studio for database development (branching, merging, etc).
In Azure, I do the following:-
The repo only has a ".gitignore" file in it.
In Visual Studio (2022), these are the steps I've taken:-
The issue arises when I try to connect my VS project to my Azure repo.
To attach the project to Azure, I do the following:-
I can see VS stage the changes and then I get the following error:-
"rejected Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes before pushing again."
I can't figure out where I'm going wrong so any help would be greatly appreciated.
Once I get this sorted out, I'll be moving on to branching/merging (and we need to attached the branch to a different database) but I'll get to that bit in the future.
Regards
Richard
August 4, 2023 at 11:01 am
can you add a screenshot of the window in visual studio where you select existing remote?
It sounds like you need to do a sync/pull first.
August 4, 2023 at 1:02 pm
Yep. Pull first, then add stuff. You can't sync the two independently. One has to drive the other, especially initially.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
August 7, 2023 at 4:58 am
Hi both
Thanks for the responses.
@winston - I've attached the screenshot as requested
@both - I don't get the option to do a pull first (unless I'm doing something wrong).
I'm following the guide here:-
Getting started with Database Projects and Version Control (oliviervs.be)
I'm happy with creating the Azure project/repo but just can't get the Push to work.
Regards
Richard
August 7, 2023 at 8:50 pm
Go to the folder for the repo with a command line and type "git status". What do you get?
With VS, should be an option to just pull: https://learn.microsoft.com/en-us/visualstudio/version-control/git-fetch-pull-sync?view=vs-2022#pull
If there isn't, my guess is you create files in the local folder and then are trying to merge that with the remote. You should create the repos first and link them, then create your project.
This likely is easy to fix in the command line. In VS, not so much. When you do this, you want to create a repo in one place only. Don't add files in the Azure repo (git remote) and add them locally. I'd have created an empty Azure DevOp repo, then created the local one from VS and then added the remote and pushed there.
August 8, 2023 at 10:06 am
@steve-2 - When I do the initial bits to get the stored procedures, etc into VS, there is no git subfolder in the project folder. It appears to be a holding folder for the solution/project.
That doesn't appear until I try to do the initial commit/push (from the screenshot I posted).
I've tried creating an empty DevOps repo but I always end up with either a README and/or a gitignore file depending on the options I choose (I think this is what's causing the issue).
How do I create a completely empty repo?
I've tried variations of options when I initialise the repo but I always end up with something in there.
Regards
Richard
August 8, 2023 at 5:12 pm
OK, so it seems you might not know the basics of Git. I would assume when you create a VS project, you can set make this a git repo. If not, create a new folder and from the command line "git init" will do that.
Alternatively, you can create a repo in Azure DevOps and then git clone the URL. For example in AzDO, I can create a new project:
When I look at this in Repos, I see this> I'd assume you see this. Note, I didn't click "initialize" at the bottom.
Once I have this, I can clone this in VS with the drop down.
I can also grab that URL (copy next to the top edit box) and type "git clone <url>" with the URL in that spot. That will clone to a subfolder below where the current command line is.
If I've create a repo with my VS project, I'd use the second section to do the git remote add origin from the VS folder and then push changes.
August 15, 2023 at 8:29 am
Thanks Steve - that worked (I was initialising the repo when I didn't need to)
Another (hopefully easy) question, is it possible to have the branch point the database to a different connection automatically?
For example:-
My main database is "DummyDatabase"
My development database is "cl_DummyDatabase"
When I create the branch, can I get the connection to change from "DummyDatabase" to "cl_DummyDatabase" without me going into the properties and updating the connection string?
Thanks
Richard
August 15, 2023 at 4:51 pm
You might be able to do this programmatically through GitHub actions or workflows. I haven't done this, so I'm a little unsure what would be best.
Generally, even when branching databases, I keep the database names the same because of the issues you can run into along these lines. If you want to work on a branch, rebuild the db to that branch.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
August 16, 2023 at 8:14 am
Thanks Grant - I'll have a look at those.
We currently use SQL Clone to create our development databases so was just wondering if I could get the branch to point to the clone automagically somehow.
I'll keep digging.
Regards
Richard
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply