Git Version Control System
Instalation
On a Debian-based distribution, such as Ubuntu
On Windows download and install from git-scm.com.
Configure your user name and email address:
$ git config --global user.name "exampleusername"
$ git config --global user.email "example@gmail.com"
Creating repositories
Create a new local repository
Clone an existing repository
Grab the https
or ssh
path from the remote (Github, GitLab, etc...) and then run:
Working locally
Check the status of our repository:
When we create a new file git
becomes aware of it but it is still not tracking changes to that file. To instruct git
to track a file run:
Now git
is tracking the file but changes haven't been recorded as a commit yet. A commit is a record of a change. This change will be permanently recorded in our history, and can be reverted to at a later date. To make a commit we use git commit
. We also add a message which should be a short desciption of changes made.
The -m
flag allows us add a short message to each commit. A good commit message should give a brief statement of any changes made to the file.
To commit all local changes in tracked files (however this is generally discouredged):
We can lookup recent changes made to our repository with:
Working with remote repository
To push your local changes to the remote repository we use the following command:
To pull the current version of the repository from the remote server use:
If your default branch is different than master, you will need to specify the branch name:
Remove a file from version control
Remove the file from the Git repository but not from the filesystem:
If you want to remove a whole folder, you need to remove all files in it recursively.
Then push changes to remote repo: