Here is a basic work flow when you work with Git and a master on GitHub or GitLab.
Lets start with an overview of some basic commands.
||Do a healthcheck and see how you local changes reflect to the current repo and its master.|
||Add a specific file to the repo.|
||Add all files in the current directory.|
||Push all committed changes to your master.|
||Update your local repo with and files changed on the master. Useful then updating the repo from several places.|
||Add a tag to your repo and attach a tag message.|
||Push the tags to your master.|
The commands are further explained below.
Git is the code versioning tool, it is used to provide version management to software code and equal documents.
GitHub and GitLab are two examples on websites that hosts git repos and provide additional services to work with the repo.
You have installed Git and you have a existing repo available to play around with.
When you install Git you will get a terminal named Git Bash with it (Windows). It is a Unix terminal that makes it possible to write git commands and work with the repo. MacOS and Linux already have a Unix terminal
Here are som commands that are useful in a Unix terminal.
||Show all files and directories in the current directory.|
||Show additional details on the files and directories.|
||Show even the hidden files, those starting with a dot
||Do it all.|
||Create a new directory named
||Change to a sub directory named
||Change one directory up in the directory hierarchy.|
||Change directory to your home directory.|
||Show the current working directory.|
||Create a new file named
||Show the content of the file.|
||Show the content of the file and paginate its output.|
Try to open up Git Bash (or Terminal in MacOS or any Linux terminal) and play around with the commands above to see how they works.
Check the status of the repo
Go to your repo (change directory to your repo).
You can check a status of a repo.
It is sort of a health check on the repo and it compares your local version (your local branch master) with the remote version (your origin/master).
Add a file to the repo
Go to your repo and create a new file
# Go to your repo touch test.html ls -l
You can open the file in your texteditor and add some sample text into it, just for the fun of it.
git status to see how it looks.
We shall now add the file to the repo.
git add test.html
The file is added to the repo.
An alternative is
git add . which add all files to the repo.
You can now do another
Commit all changes
When you are done with all your additions, and changes, then you shall commit them. It is like permanent writing your updates into the repo.
git commit -a -m "First commit"
-a means all files that are changed and
-m "First commit" is a commit-message attached to this commit, explaining what the commit was about.
You can also commit only one file at the time.
git commit test.html -m "First commit"
You can the check with
Push changes to your master
When you are done with all commits you should push them all to your master.
The changes are now uploaded and you can reload your repo page on your website to check that all changes were uploaded.
You are now up to date with your master.
Get updates from the master
If there are changes to the master that you have not yet downloaded locally, then do like this.
Your local repo is then updated to mirror the master.
Create a tag and push it
When you have a certain baseline in your project, you mey want to tag it with a version number. This makes it easier to know tha status of the repo.
git tag -a v1.0.0 git push --tags
You can add a new tag at any stage.
You need to push the tags separately, by adding