Table of contents
- 1. Getting the source (-+git clone+-)
- 2. Repository status (-+git status+-)
- 3. Status of untracked files (-+git status -u+-)
- 4. Reading history (-+git log+-)
- 5. Adding changes and files (-+git add+-)
- 6. Removing files from Git (-+git rm+-)
- 7. Committing changes (-+git commit+-)
- 8. Creating branches (-+git branch+-)
- 9. Sending work to remote repository (-+ git push+-)
- 10. Fetching updates (-+ git pull+-)
Tiki repository has a huge size and a regular clone will take a lot of time. If the purpose of the clone is Tiki development, including master and other branches, it is needed to clone the entire repository.
git clone email@example.com:tikiwiki/tiki.git tiki
But when using a continuous integrations system or any kind of automation process depending on latest Tiki source, it possible to create a shallow clone, which will bring just the last source code version.
git clone --depth 1 firstname.lastname@example.org:tikiwiki/tiki.git tiki
Some developers have multiple folders per branch, but it does not means they have a full clone per folder. They clone the full repository once and then, they clone other branches, but referencing the full clone folder.
git clone email@example.com:tikiwiki/tiki.git tiki-reference
Supposing a developer wants to clone also the branch 18.x, but without cloning the entire repository, the following command should be used.
git clone --branch=18.x --reference=tiki-reference firstname.lastname@example.org:tikiwiki/tiki.git tiki18x
You can read about changed files, untracked files and how far is your local repository from the remote repository by using the
git status command. More information can be found by typing
git help status.
The command below will list all ignored files present on working copy. This is useful when trying to commit a file that should be on repository, but it is ignored by a rule present on
git status --ignored
Sometimes, depending the task, it is possible that working copy contains a lot of untracked files. But it is possible to check working copy status excluding those files.
git status -u no
But there are other occasions that is needed to check all untracked files, including files on sub-directories.
git status -u
To read the commit log, container authors, data and commit messages, you can use the command
It is possible to filter logs by author and date, like snippets below demonstrate.
git log --author=jonnybradley # --author can be used multiple times git log --author=jonnybradley --author=drsassafras
git log --since=2018-03-01 # --since is the start date, and --until is the end date git log --since=2018-03-01 --until=2018-04-31
git log --since=2018-03-01 --until=2018-04-31 --author=jonnybradley --author=drsassafras
For more options, try
git help log
Before committing, the changes you did should be marked to commited. So, when you tell git to commit your changes, only files you marked to be committed will be committed.
echo 'My new super file' > src/foo.txt echo 'Other super file' > src/bar.txt git add src/foo.txt src/bar.txt
It is possible to add all changes from a folder at once. It also works to add changes from entire working copy, but it is not a good practice.
echo 'My new super file' > src/foo.txt echo 'Other super file' > src/bar.txt git add src git commit -m '[NEW] Add new super feature to Tiki'
git rm src/foo.txt git commit -m '[FIX] Removed unused file'
After all new or changed files are marked to be committed by using
git add, or files were removed by using
git rm, it is time to commit these changes to local repository.
git status git commit -m '[NEW] Descriptive message about my changes'
There are occasions a developer commits changes from someone else, in this case, is possible to give the commit the correct author identity.
git commit --email@example.com -m '[FIX] Options list for editable icon preference'
When there are changes just on versioned files, there is shortcut to commit these changes at once, by adding
-a parameter on git commit.
git commit -a -m '[NEW] Descriptive message about my changes'
Creating branches is easy and fast on Git. It is a good idea to have different branches for tasks, features or experiments and keep master branch clean, so you can fetch updates regularly without dealing with conflicts.
# create the branch git branch task-icon-picker # and then switch to branch git checkout task-icon-picker
There is a shortcut to create a branch and then switch to it.
git checkout -b task-icon-picker
If this local branch is needed for other team mates, it is possible to make it available on remote repository.
git push -u origin task-icon-picker
Let's suppose you are working on branch *bugfix-foo*, and you want update your branch with branch master changes.
git checkout bugfix-foo # switch to branch git merge master # bring master changes to current branch
To send your new commits on your local repository to the remote repository, just use the command
git push. The command below will send all changes on local branch to the remote branch on remote repository.
It is a good practice stay always up to date with remote repository your team is using. This way you avoid a lot of conflicts. To get remote changes and bring to local repository and working copy, use the command
The command below will fetch updates from remote repository.
After fetching changes, the local repository and branch should be updated with it. Supposing the branch to be updated is the
master, and the current local branch is also
master, it is possible to apply changes with the command below.
git merge origin/master
There is a shortcut to fetch and apply changes on current branch, like below.