C
C#4d ago
Faker

✅ Using git in rider

Hello guys, it's my first time using a version contrl system (git) on rider. When I need to choose my "unversioned" files to commit, I have my .cs files where my codes are but also, I have my solution and my project folder. Can I just add my solution and just leave everything else as they are? Or will this track unnecessary files like .dll files or other files that are hidden. Or I need to specifically choose the folder I want where my .csproj is ?
28 Replies
Faker
FakerOP4d ago
well I don't have my project folder but I have the .csproj file of that folder but I do have the solution though
Faker
FakerOP4d ago
No description
No description
Faker
FakerOP4d ago
see there are a lots of hidden files by default, so if I choose my .csproj or solution directly, will this also keep track of these files? (we don't want to keep track of them, right ?) Or I noticed that we have a .gitignore which is automatically generated, may be it already contains pattern to exclude those files?
Angius
Angius4d ago
Create a default .gitignore file A bunch of those files, like everything in /obj or /bin doesn't need to be commited dotnet new gitignore if you need to generate it
Faker
FakerOP4d ago
hmm the thing is, I can't see the obj or bin folder, I think I only see what's in there
No description
Angius
Angius4d ago
They're not visible in the project view, since you're not meant to interact with them manually
Faker
FakerOP4d ago
may be the problem is this:
No description
Faker
FakerOP4d ago
noticed I created my .git folder outside my project folder
Angius
Angius4d ago
Rather, the issue is that the .gitignore is not on the solution level
Faker
FakerOP4d ago
yeah, I'm lost :c.... why is the .gitignore not in the same location as the .git folder? Was it a good idea to create the .git folder in the solution level? Notice this image, the user can directly add a folder directly to a gitignore file
No description
Angius
Angius4d ago
You want a structure like this:
MyCoolProject
├─ .git
├─ .idea
├─ MyCoolProject
│ ├─ MyCoolProject.csproj
│ ├─ Program.cs
│ └─ SomeOtherFile.cs
├─ MyCoolProject.sln
├─ .gitignore
├─ README.md
└─ LICENSE.md
MyCoolProject
├─ .git
├─ .idea
├─ MyCoolProject
│ ├─ MyCoolProject.csproj
│ ├─ Program.cs
│ └─ SomeOtherFile.cs
├─ MyCoolProject.sln
├─ .gitignore
├─ README.md
└─ LICENSE.md
Faker
FakerOP4d ago
yeah I see, here the .gitignore is not there
Angius
Angius4d ago
Yep Open the terminal in Rider, and just do dotnet new gitignore in the solution dir
Faker
FakerOP4d ago
yep
Faker
FakerOP4d ago
it would be wrong to just move the .gitignore files where the unversioned files was pointing to? I noticed there are already some contents in them but the bin or obj folder is not included though, have a look
No description
Angius
Angius4d ago
That's Rider's default gitignore
Faker
FakerOP4d ago
yeah, I will just let it here, I created the .gitignore, look how clean the unversioned file is now
No description
Angius
Angius4d ago
Yep
Faker
FakerOP4d ago
nice, now the thing is, should I keep track of the solution itself or the csproj? or this depends on what I want, like to keep track of everything globally or just related to this project?
Angius
Angius4d ago
Wym "keep track of"?
Faker
FakerOP4d ago
like, the unversioned files are the files not in the staging area (I think), so in order to commit the changes, I can either add the .csproj which is related to only 1 project or the solution which is global no? (I think, may be I'm wrong :c)
Angius
Angius4d ago
Add everything in the repo Solution isn't in any way global It's just a way to keep multiple projects together
Faker
FakerOP4d ago
oh I see, I think I had a missconception... please, consider these image: I'm confused here, the .sln folder contains details about how each project are related (I obtained it just to have a look of what it looks like and it's organised as above). What I don't understand is, the LibraryManagement, is just a simple folder? Because look at my IDE, it shows "solution" but a solution isn't just a file, like the .sln file ?
No description
No description
No description
Angius
Angius4d ago
The folder that has .sln or .slnx file in it is shown as the purple one, the solution The folder that has .csproj file in it is shown as the green one, the project They are simple folders, in no way special Rider and other IDEs just show them in this more conceptual way, rather than raw filesystem tree You'll notice that Rider doesn't actually show the .sln and .csproj files here But you can right-click the green "folder" and get all the .csproj settings Or even edit it as text
Faker
FakerOP4d ago
oh ok
Faker
FakerOP4d ago
Yeah, in fact, I just noticed that we can just switch from "Solution to File system" in rider, here is what it looks like
No description
Angius
Angius4d ago
yep
Faker
FakerOP4d ago
yep I see, make more sense now, I thought that a solution was a special folder but it's just a "special" file works fine now, thanks once more !

Did you find this page helpful?