How to Use Git and GitHub in Termux — Complete Version Control Guide on Android 2026
// 01 — Introduction
If you've ever wanted to manage your code, collaborate on projects, or back up your work — all from your Android phone — then learning how to use Git and GitHub in Termux is one of the most powerful skills you can develop. In 2026, mobile development has exploded, and Termux has become the go-to Linux terminal emulator for Android users who want real development capabilities right in their pocket.
Git is the world's most popular version control system. It tracks every change you make to your code, lets you roll back mistakes, and enables seamless collaboration with other developers. GitHub, on the other hand, is the cloud platform where millions of developers store, share, and collaborate on their Git repositories. Together, Git and GitHub form the backbone of modern software development — and yes, you can use both of them fully from Termux on your Android device, no root required.
In this complete guide by Rixon Xavier, you'll learn everything from installing Git in Termux to cloning repositories, making commits, pushing code to GitHub, handling branches, and solving the most common errors that beginners face. Whether you're a student learning to code, a cybersecurity enthusiast managing your tools, or a developer who wants to work on the go, this tutorial has everything you need.
By the end of this post, you'll be able to use Git and GitHub in Termux just as comfortably as any desktop developer. Let's get started!
// 02 — What is Git and Why Use It in Termux?
Before we dive into the installation and commands, it's important to understand what Git actually is and why using it inside Termux is such a powerful combination for Android users.
What is Git?
Git is a free, open-source distributed version control system created by Linus Torvalds in 2005 — the same person who created the Linux kernel. It was designed to handle everything from small to very large projects with speed and efficiency. Git tracks changes in your source code during software development and allows multiple developers to work on the same project simultaneously without overwriting each other's work.
At its core, Git works by taking "snapshots" of your files at different points in time. These snapshots are called commits. Every commit has a unique ID, a message describing the change, and a record of exactly what was modified. This means you can always go back to any previous version of your project if something goes wrong.
What is GitHub?
GitHub is a web-based hosting service for Git repositories. Think of it as a cloud storage platform specifically designed for code. GitHub provides a visual interface for your Git repositories, lets you collaborate with other developers, report issues, review code changes, and much more. It's owned by Microsoft and is used by over 100 million developers worldwide.
Why Use Git in Termux?
Termux gives you a full Linux environment on your Android phone. This means you can run the exact same Git commands that developers use on their laptops and desktops. Here's why this is incredibly useful:
Work anywhere: Your phone is always with you. With Git in Termux, you can commit code changes, pull updates, and push your work to GitHub from anywhere — on the bus, in a cafe, or during a break.
Manage cybersecurity tools: Many ethical hacking and cybersecurity tools are hosted on GitHub. With Git in Termux, you can clone these tools directly to your phone and keep them updated with a single command.
Learn real development skills: Using Git from the command line teaches you how it actually works under the hood — something that GUI tools hide from you. This makes you a better and more confident developer.
Backup your scripts: If you write Termux scripts, automation tools, or configurations, Git lets you back them up to GitHub and access them from any device.
// 03 — Installing Git in Termux
Installing Git in Termux is straightforward and takes less than a minute. Follow these steps carefully.
Step 1 — Update Termux Packages
Before installing anything, always update your package list to make sure you're getting the latest version of Git. Open Termux and run:
pkg update && pkg upgrade -y
This command updates all your existing packages and ensures your system is ready. It may take a minute or two depending on your internet connection.
Update Package List
Always run pkg update before installing new packages to avoid version conflicts.
Step 2 — Install Git
Now install Git using Termux's package manager:
pkg install git -y
Install Git Package
The -y flag automatically confirms the installation without asking you to type "yes".
Step 3 — Verify Installation
After installation completes, verify that Git was installed correctly by checking its version:
git --version
You should see output like this:
git version 2.43.0
Verify Git Version
If you see a version number, Git is installed and ready to use in Termux.
// 04 — Configuring Git and Connecting to GitHub
After installing Git, you need to configure it with your identity and connect it to your GitHub account. This is a one-time setup that Git uses to sign your commits.
Set Your Username and Email
Git needs to know who you are so it can attach your name and email to every commit you make. Run these two commands, replacing the values with your own information:
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Set Default Branch Name
GitHub uses main as the default branch name. Set Git to use the same:
git config --global init.defaultBranch main
Verify Your Configuration
Check that your configuration was saved correctly:
git config --list
Connecting to GitHub — Personal Access Token (PAT)
GitHub no longer accepts passwords for Git operations over HTTPS. Instead, you need a Personal Access Token (PAT). Here's how to get one:
Go to GitHub Settings
Open github.com → Click your profile picture → Settings → Developer Settings → Personal Access Tokens → Tokens (classic) → Generate new token
Set Token Permissions
Give it a name like "Termux", set expiration, and check the repo scope for full repository access. Click Generate token.
Save Your Token
Copy the token immediately — GitHub only shows it once! Save it somewhere safe. You'll use this as your password in Termux.
Save Credentials in Termux
To avoid typing your token every time, store your credentials:
git config --global credential.helper store
The first time you push or pull, Git will ask for your GitHub username and token. After that, it remembers them automatically.
Alternative — SSH Key Authentication
For better security, you can use SSH keys instead of a token. Generate an SSH key in Termux:
pkg install openssh -y
ssh-keygen -t ed25519 -C "your@email.com"
cat ~/.ssh/id_ed25519.pub
Copy the output and add it to GitHub → Settings → SSH and GPG keys → New SSH key. Now you can use SSH URLs when cloning repositories.
// 05 — Essential Git Commands in Termux
Now that Git is installed and configured, let's learn the most important Git commands you'll use every day. Understanding these commands is the foundation of using Git in Termux effectively.
Initialize a Repository
To start tracking a project with Git, navigate to your project folder and initialize a Git repository:
mkdir myproject
cd myproject
git init
This creates a hidden .git folder inside your project directory that stores all version history.
Check Repository Status
This is one of the most used Git commands. It shows you which files are modified, staged, or untracked:
git status
Stage Files for Commit
Before committing, you need to "stage" the files you want to include. Staging lets you choose exactly which changes to include in a commit:
# Stage a specific file
git add filename.py
# Stage all changed files
git add .
# Stage all files of a specific type
git add *.py
Commit Your Changes
A commit is a snapshot of your staged files. Always write a clear, descriptive commit message:
git commit -m "Add login feature"
View Commit History
See all past commits in your repository:
# Full log
git log
# Compact one-line log
git log --oneline
# Visual branch graph
git log --oneline --graph --all
Working with Branches
Branches let you work on new features without affecting the main codebase. This is essential for team collaboration and safe experimentation:
# List all branches
git branch
# Create a new branch
git branch feature-login
# Switch to a branch
git checkout feature-login
# Create and switch in one command
git checkout -b feature-login
# Merge a branch into main
git checkout main
git merge feature-login
# Delete a branch after merging
git branch -d feature-login
Undo Changes
One of Git's most powerful features is the ability to undo mistakes:
# Unstage a file (keep changes)
git restore --staged filename.py
# Discard changes in working directory
git restore filename.py
# Undo last commit (keep changes staged)
git reset --soft HEAD~1
# Undo last commit (discard changes)
git reset --hard HEAD~1
git reset --hard permanently deletes your uncommitted changes. Use with caution!// 06 — Working with Repositories — Clone, Push, Pull
The real power of using GitHub with Termux comes from syncing your local work with remote repositories. These three operations — clone, push, and pull — are the foundation of collaborative development.
Clone a Repository
Cloning downloads a complete copy of a remote repository to your Termux environment. This is how you get tools, projects, and code from GitHub:
# Clone via HTTPS
git clone https://github.com/username/repository.git
# Clone via SSH
git clone git@github.com:username/repository.git
# Clone into a specific folder
git clone https://github.com/username/repo.git myfolder
# Clone only the latest commit (faster for large repos)
git clone --depth 1 https://github.com/username/repo.git
--depth 1 when cloning large cybersecurity tools in Termux. It downloads only the latest version and saves storage space on your phone.Add a Remote Repository
If you initialized a local repository and want to connect it to GitHub, first create a new repository on GitHub (without README), then link it:
# Add remote origin
git remote add origin https://github.com/username/repo.git
# Verify remote was added
git remote -v
# Change remote URL
git remote set-url origin https://github.com/username/newrepo.git
Push Your Code to GitHub
Pushing uploads your local commits to the remote GitHub repository:
# Push to main branch (first time)
git push -u origin main
# Push after first time
git push
# Push a specific branch
git push origin feature-login
# Force push (use carefully!)
git push --force
Pull Updates from GitHub
Pulling downloads the latest changes from the remote repository and merges them into your local branch:
# Pull latest changes
git pull
# Pull from specific branch
git pull origin main
# Fetch without merging (safer)
git fetch origin
git diff origin/main
Fork and Contribute to Open Source
Want to contribute to an open source project? Here's the workflow using Git in Termux:
Fork the Repository
Go to the GitHub repository and click Fork. This creates your own copy.
Clone Your Fork
Run: git clone https://github.com/yourusername/repo.git
Create a Branch and Make Changes
Run: git checkout -b fix-bug then make your edits.
Push and Create Pull Request
Run: git push origin fix-bug then go to GitHub and open a Pull Request.
// 07 — Common Errors and Fixes
Error: "Permission denied (publickey)"
Permission denied (publickey).
Fix: You're using SSH but haven't added your SSH key to GitHub. Either switch to HTTPS or add your public key to GitHub Settings → SSH Keys.
Error: "remote: Support for password authentication was removed"
remote: Support for password authentication was removed on August 13, 2021.
Fix: Use a Personal Access Token instead of your GitHub password. Generate one at GitHub → Settings → Developer Settings → Personal Access Tokens.
Error: "fatal: not a git repository"
fatal: not a git repository (or any of the parent directories): .git
Fix: You're running a Git command outside a repository. Either run git init or navigate into a cloned repository folder.
Error: "CONFLICT — Merge conflict"
Fix: Open the conflicting file and look for conflict markers:
# View conflicting files
git status
# Edit the file in nano and resolve conflicts manually
nano conflicted_file.py
# After fixing, stage and commit
git add .
git commit -m "Resolve merge conflict"
Error: "Updates were rejected"
! [rejected] main -> main (fetch first)
Fix: Pull the latest changes first, then push:
git pull origin main --rebase
git push origin main
// 08 — Pro Tips for Git in Termux
.gitignore file to exclude files you don't want tracked (like API keys, passwords, or large files). Run: echo "*.env" >> .gitignoregit config --global alias.st status lets you type git st instead of git status.git stash to temporarily save your changes and git stash pop to restore them.pkg install gh for even more powerful GitHub operations directly from the terminal.git pull regularly to keep them updated with the latest fixes and features from the developer.// 09 — Git vs GitHub — Key Differences
| Feature | Git | GitHub |
|---|---|---|
| Type | Software / Tool | Cloud Platform / Website |
| Works Offline | ✅ Yes | ❌ No |
| Installation | Installed in Termux | Account on github.com |
| Storage | Local device | Cloud (remote) |
| Collaboration | Limited | ✅ Full team features |
| Cost | Free | Free (with paid plans) |
| Required | ✅ Yes (core tool) | Optional (but recommended) |
| Purpose | Version control | Hosting + Collaboration |
// 10 — Frequently Asked Questions
git config --global credential.helper store. The first time you authenticate, Git will save your credentials. From then on, you won't need to enter your username and token again. Alternatively, set up SSH key authentication for a more secure approach.git fetch downloads changes from the remote but does NOT merge them into your local branch. It lets you review changes before applying them. git pull downloads AND merges in one step. For beginners, git pull is simpler. For careful work, use git fetch followed by git merge.git clone https://YOUR_TOKEN@github.com/username/private-repo.git. Or set up SSH authentication and use the SSH clone URL. Make sure your token has the repo scope enabled.git clone. Always use tools only on systems you own or have explicit permission to test. Visit hydratermux.blogspot.com for tutorials on specific tools.git pull. This downloads and applies the latest updates from the developer. It's much better than deleting and re-cloning because it only downloads what changed.// 11 — Conclusion
You've now learned everything you need to use Git and GitHub in Termux like a pro. From installing Git and configuring your identity, to cloning repositories, making commits, pushing code to GitHub, working with branches, and fixing common errors — you have a complete toolkit for version control on Android.
Git is not just for professional developers. Whether you're a student learning to code, a cybersecurity enthusiast managing your tools, or someone who just wants to back up their scripts — Git in Termux gives you real, professional-grade version control right in your pocket. No root required, no expensive laptop needed.
The best way to get comfortable with Git is to practice. Create a test repository, make some changes, commit them, push to GitHub, and experiment with branches. The more you use it, the more natural it becomes. Before long, git add, git commit, and git push will feel as natural as typing any other command.
If you found this guide helpful, share it with your friends who use Termux and subscribe to HYDRA TERMUX for more free tutorials on Termux tools, Linux commands, and ethical cybersecurity. Drop a comment below if you have any questions — we read every single one!

Comments
Post a Comment