#How to see whats in remote repository
#How to restore one file from repsitory git/filex
#get remote values
# Files in origin/main

git ls-tree -r origin/main --name-only

# Files in origin/master
git ls-tree -r origin/master --name-only
exit
appname="git"
git ls-remote $git
# or just branches:
git ls-remote --heads $git
# or just tags:
git ls-remote --tags $git
exit
apps="git"
DEFAULT_BRANCH="main"
echo "List files in Git";
ver=`git log --oneline | sed "s/ .*//g"`;
echo "ver = $ver" 
# List files in a specific commit 'a1b2c3d4'
git ls-tree --name-only -r $ver
exit
#How to list files and versions
#How to add version number to files
#How to commit files to git
git add .
#How to commit files to repository
#how to see files in remote repository ?
#how to see files in local/remote repository ?

#create main repository for apps
apps="git"
DEFAULT_BRANCH="main"
#git init --bare ~/websites/gitrepo/$apps.git

#setup files to repository
DEFAULT_BRANCH="main"
  ##  git init
    ##git branch -M "$DEFAULT_BRANCH"
  git add .
  git commit --allow-empty -m "Initial commit" || true

exit
git tag -a v1.0 -m "First version"
git log --oneline
git ls-tree --name-only -r 1a0cc04
set -x
  info "Pushing to remote: $remote_url"
  git push -u origin "$DEFAULT_BRANCH"

  info "App repo '$app_name' created and pushed."
#Commands

## Common Commands

Step 1
# Initialize a empty repository
git init

# Create a ignore file so we do not track heavy Python cache folders
echo "__pycache__/" > .gitignore
echo ".DS_Store" >> .gitignore

# Stage all your current project files
git add index.php api.php scraper.py stocks.json .gitignore

# Commit your files as Version 1.0
git commit -m "Feat: Complete fully working v1.0 tracking dashboard"

# Create a v1.0 tag checkpoint
git tag -a v1.0 -m "Stable v1.0 release with fixed Bootstrap CDN"
git tag -a v5.0 -m "v5 working release - includes viewmd.sh"
# Step 2 how to check repository
git log
git log --oneline
git ls-tree --name-only -r 1a0cc04

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   diff       Show changes between commits, commit and working tree, etc
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   backfill   Download missing objects in a partial clone
   branch     List, create, or delete branches
   commit     Record changes to the repository
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   reset      Reset current HEAD to the specified state
   switch     Switch branches
   tag        Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects


1. Show Version Numbers (Commits)
To see a list of all commits, which represent the version history:
git log
This shows commit hashes, author, date, and commit messages.
For a simplified view with only commit hashes and messages:
git log --oneline
Example output:
a1b2c3d4 Update README file
e5f6g7h8 Fix bug in authentication
i9j0k1l2 Initial commit
The alphanumeric strings (a1b2c3d4) are the commit hashes (version identifiers).
2. List Files in a Specific Commit or Version
To see the files in a specific commit:
git ls-tree --name-only -r <commit_hash>
--name-only: lists only file names
-r: recursively lists files in all directories
<commit_hash>: the commit hash you want to inspect
Example:
git ls-tree --name-only -r a1b2c3d4
This will list all files as they existed in that version.
3. Retrieve Files from a Specific Version
To check out a specific file from a commit:
git checkout <commit_hash> -- path/to/file
To check out the whole repository at a specific commit (detached HEAD):
git checkout <commit_hash>
After inspecting, you can return to the latest version:
git checkout main
(Replace main with your current branch name if different.)
4. Retrieve the Latest Version
To make sure your local repository has the latest commits from the remote:
git fetch origin
git pull origin main
git fetch updates remote tracking branches without changing your working files.
git pull fetches and merges changes to your current branch.
After this, your repository is up-to-date with the latest version.
5. Additional Tips
To view a commit’s full details including files modified:
git show <commit_hash>
To list only the files changed in a commit:
git diff-tree --no-commit-id --name-only -r <commit_hash>
Example Workflow
# Check recent version numbers
git log --oneline

# List files in a specific commit 'a1b2c3d4'
git ls-tree --name-only -r fb26750 

# Retrieve a specific file from that commit
git checkout a1b2c3d4 -- README.md

# Update to latest version from remote
git pull origin main
By following these commands, you can easily inspect historical versions, list
files within them, and ensure your repository is at the latest version.

Press ENTER or type command to continue

