mandag den 6. juni 2022

Adding a project to GitHub

At my current work, we use git for managing our project repositories, and while I know that not everyone uses git, I felt like I should make a small write-up of how to make a project repository and commit your project to it.

Even though we use GitLab at work, the process is largely the same for GitHub, which is what I'll be using for this blog.


Initially, you want to make sure you have a git client installed on your computer. I personally mostly use git-cmd which is included in TortoiseGit (I use TortoiseGit for inspecting logs and resolving more complex merge conflicts etc.). 

I will be adding the .NET MAUI project I have made as a part of my 2 previous blogposts to GitHub, so it is easier for people to check my code out, but also to be able to give some examples in the future, of what a workflow in git could look like.


I will start by creating a new repository on GitHub, which can be done under the "Repositories" tab by clicking the "New" button:


This brings me to the page where I can configure my new repo, which looks like this:


Here I choose to set the Repository name to MAUI-samples, as this repository will contain multiple .NET MAUI sample projects, in addition, I add a .gitignore file with the template "VisualStudio" since a Visual Studio project contains some files that we don't want to include in our git repository, and I also add a README file in which I will document the purpose of this repository.


After creating the new repository, I have to commit the project to the repository, and for that, I need the URL of the git repository, which can be found here:


Since this repository will contain multiple sample solutions, I will clone the remote repository, and then simply copy over my existing solution to the newly created repository.



Now after copying over the solution, I will have to add the untracked files to the git index, commit the changes and push to the remote repository.


A brief explanation of the commands:
  • git status - pretty much self-explanatory, but basically shows you the current branch and whether it is up-to-date with the remote branch, as well as and untracked files or uncommitted changes.
  • git add -A - adds files to the git index, -A is the option for "all files".
  • git commit -m "commit message" - Commits the current changes with the commit message provided (-m is the message option).

All that is left now is to push the changes to the remote repository using the git push command:



After refreshing my repository page on GitHub, you can see that the changes have been committed and the files have been added:


The repository can be found here, and I will be adding more content and code to it as I write more posts.

Ingen kommentarer:

Send en kommentar