18. Version Control Basics using Git in Termux
Continuing from the Git installation, let's cover the basic workflow for tracking a new project.
1. Initializing a Repository
To start tracking files in a folder, initialize a Git repository there:
bash $ mkdir my_new_project $ cd my_new_project $ git init Initialized empty Git repository in /home/my_new_project/.git/
2. Status Check (git status)
This command shows which files have been modified or are untracked.
bash
$ touch readme.md
$ git status
Untracked files:
(use "git add
3. Staging Changes (git add)
Before you commit, you must stage the files (tell Git which changes you want to include in the next save point).
bash
Stage a specific file
$ git add readme.md
Stage all changes in the current directory
$ git add .
4. Committing Changes (git commit)
Committing saves the staged changes to the repository history, along with a mandatory descriptive message.
bash $ git commit -m "Initial commit: added README file"
5. Viewing History (git log)
To see a chronological list of all commits in your repository:
bash $ git log
This basic workflow (init, add, commit) is the foundation of using Git on your mobile device.