Some Git Basics
An Introduction to Git
Some Git Versioning basics
Here are some Git versioning basic how to’s for creating and updating a new project or repository. More detailed guides and reference materials can be viewed at https://git-scm.com. More specifically first time setup can be found on this guide: here
Setting up git on your machine
Once git is installed (See Here if you have not done so yet), we need to setup your username, and email details, as well as the repo’s upstream remote origin location.
To setup your username and email for every repository:
$ git config --global user.name "my name"
$ git config --global user.email "my.email@example.com"
And to check or view username once set:
$ git config --global user.name
> my name
And to check or view email once set:
$ git config --global user.email
> my.email@example.com
To setup your username and email for a single repository:
$ git config user.name "my name"
$ git config user.email "my.email@example.com"
And to check or view username once set:
$ git config user.name
> my name
And to check or view email once set:
$ git config user.email
> my.email@example.com
Creating a new Repository
Creating a repository can be done in a few clicks. Simple to follow guide Here from the Github help docs page.
Once the repo is created on the remote side, we can pull/push updates from our local machine.
Pulling from remote
To pull an existing project from the remote (github) location to you local machine, you can use the “clone” command.
Using “Https”
$ git clone "https://github.com/your_name/your_remote_repo/"
Using “SSH”
$ git clone "git@github.com:user_name/your_remote_repo.git"
Pushing from the Local machine
To setup a folder to hold/manage a new git project, you can call ‘git init’ when in the target directory.
$ git init
This should generate a “.git” folder.
Creating a git tag.
Sometimes its helpfull to keep track of particular commits. One of the ways to do this, is the use of a Git Tag.
You can easily create one, using some basics commands:
This should list any existing tags that have been created for the project/repo.
$ git tag
The following creates a new anotated (-a flag) tag of v1.0, with the description (-m “text here” flag) “my version v1.0”:
$ git tag -a v1.0 -m "my version v1.0"
Once created, this can be pushed to the master origin branch by:
$ git push origin v1.0