I’m back and Git – rookie’s thoughts

Hello there!
It’s certainly been a while since my last post! It was more or less 6 months ago which is a long time but I wasn’t idle, oh no! If you briefly scan all my posts you’ll notice that my field of interests was Windows apps, mostly WPF technology and MVVM pattern. However this has recently changed – I’ve started ASP.NET app! The project is a web app for acquainted company which purpose is to organise and keep track of service jobs they provide to their client. It is not an open project so I can’t share the code at the moment. Let me say only that it is an MVC app using what comes by default with an MVC template in Visual Studio (Entity Framework, Identity, bootstrap, jQuery etc.) so as you can see a lot of new things!

Here you go a screenshot of the early version of the current app (first version is up and running, but it is very very basic so they have anything to start with). Let me stop here about this project and let’s move on to the next thing which is:

Git – my first thoughts

So, I’ve already been using GitHub (here’s my account) but recently I did a quick course on Git (on LinkedIn Learning [link]) so I thought why not to try it on my own. So I downloaded packages, created separate partition on my hard drive and installed it and started using it. As I’m a beginner I use only some basic commands that you definitely know:

  • git status – shows current changes and what’s been staged
  • git add .  – adds all changes to commit stage, the dot indicates that all files must be added, you could replace it by a specific file name
  • git commit -m”<message>” – commits staged changes to a repository with a message, I generally try to always commit with a message
  • git commit -am”<message>” – adds to stage all changes (except new files) and commits them to a repository
  • git log –x – prints out a log of a commit where x is an ordinal number of a commit (1 – is the newest)
  • git push – pushes (uploads) all commits to a remote repository

And that’s more or less it. That’s enough for me to start.
Now, a word about remote repository. You can use GitHub to host your remote repositories, they offer unlimited number but in a free plan they can only be public repositories (it’s easy to find how to set it all up on their help pages). If you’re looking for a private repo you can simply use your local drive (once you have a directory set up simply run git bash, navigate to this directory and execute git init, or start your project in Visual Studio and tick the Create new Git repository option). However if you still need the remote repository to push your commits (for instance to share the source code with others working with you on a project, or for backup) what you can do is to use Visual Studio Team Services . They offer private repositories. To set a remote address for your repo in VSTS you need to:
a) once you are registered and logged to VSTS you need to create new project with version control set to Git
b) go to https://xxx.visualstudio.com/_projects where xxx is your alias and click on your project’s name, this will bring you to project’s homepage
c) unfold second category as below
d) execute the above commands in your git bash (of course your URL will differ)

It’s all set! This basically links your local repo with a remote repo at VSTS. In the above command ‘origin’ is a name for the remote repo. If your case is that you use only one remote repository you don’t need to specify it when executing the push command in future.
So, that’s about it what I wanted to say about my first steps with git. Maybe as a side note I’d add that help files that come together with git installation are really really helpful so I encourage to look for solution there in case you encounter any problem.