Git manages project files using a three-stage architecture that governs how code transitions from local changes to committed history:
graph LR
WD["Working Directory<br>(Untracked / Modified)"] -- "git add" --> SA["Staging Area<br>(Index / Draft)"]
SA -- "git commit" --> LR["Local Repository<br>(.git database / HEAD)"]
LR -- "git push" --> RR["Remote Repository<br>(GitHub / Gitea / Bare Git Repo)"]
git add allows you to build clean, modular commits instead of committing all file modifications at once..git directory): The database where Git stores the metadata and object database containing the committed snapshots of your project’s history. Commits in this area are permanent and local to your system.A remote repository is a version of your project hosted on a separate server, a local network share, or even a different directory path on the same local server. Linking a local repository to remotes allows team collaboration and code backup.
origin: The default name Git assigns to the remote server from which the local repository was originally cloned.upstream: By convention, the name given to the parent repository that you forked from. In open-source or forks-based workflows, developers configure upstream to fetch commits and stay in sync with the primary project.origin/master) are read-only references that show the state of branches on remote servers at the time of your last connection (git fetch or git pull).git remote add <name> <url-or-path>: Links a local repository to a remote path.git remote -v: Lists all configured remote connections along with their fetch and push URLs.git remote show <name>: Inspects a remote repository in detail, displaying tracking status for branches.git remote rename <old> <new>: Renames a remote link.git remote remove <name>: Removes a remote link and deletes all corresponding tracking branches.This guide details the steps to log in to the Nautilus Storage Server, link a local repository to a new bare Git remote (dev_media), commit a staging file, and push changes to the remote.
ststor01)natasha (or designated sudo user)/usr/src/kodekloudrepos/media (or your designated repository name)dev_media/opt/xfusioncorp_media.git/tmp/index.htmlFrom the Jump Host, SSH into the storage server:
ssh natasha@ststor01
Change directory to the designated local git repository:
cd /usr/src/kodekloudrepos/media
List the active remote connections configured for this repository:
git remote -v
Expected output showing only the default origin:
origin /opt/media.git (fetch)
origin /opt/media.git (push)
Link the repository to the new development bare repository using git remote add:
sudo git remote add dev_media /opt/xfusioncorp_media.git
Confirm that the new remote has been registered correctly:
git remote -v
Expected output:
dev_media /opt/xfusioncorp_media.git (fetch)
dev_media /opt/xfusioncorp_media.git (push)
origin /opt/media.git (fetch)
origin /opt/media.git (push)
Copy the temporary static HTML file into the working directory, stage it, and commit it to the local repository:
# 1. Copy the file into the current directory
sudo cp /tmp/index.html .
# 2. Stage the file
sudo git add index.html
# 3. Commit the changes locally
sudo git commit -m "Add index.html to media repository"
Push the local master branch commits to the newly added dev_media remote repository:
sudo git push dev_media master
Expected output snippet:
Counting objects: 3, done.
Writing objects: 100% (3/3), 290 bytes | 290.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To /opt/xfusioncorp_media.git
* [new branch] master -> master
Verify that the remote dev_media tracking branch is synchronized with your local master branch:
git branch -a
Expected output:
* master
remotes/dev_media/master
remotes/origin/master
Log out of the Storage Server:
exit