- MacOS:
brew install git-lsf - Linux/Windows: Download from git-lfs.github.com
- Use
ssh-agent
eval $(ssh-agent)
ssh-add ~/.ssh/id_github_fjmalass
ssh-add ~/.ssh/id_github_fmalassenet_grumpygit init
git add README.md
git commit -m "First commit"
git branch -M main # aka --move --force
# add a remote with name `origin` (should probably use upstream)
# create the `origin` repo that link to the github repo (could have used github)
git remote add origin https://github.com/<username>/<repo>.git
git push -u origin maingit push <remoteserver> <localbranch>:<remotebranch>
git push origin main
This enables having simultaneous branches in different directories
git diff --staged` # for staged
git diff # for unstagescd Repos/Rhypt
git clone --bare git@github.com:test .bareTell git that the goodies are in a .git file
echo "gitdir: ./.bare" > .gitWorktrees based on http://www.gitkraken.com
- Check if there are any
worktrees:git worktree list - Now work on
worktrees
git worktree add main
git worktree add rolling`- Go to the directory where the repo lives, e.g.,
cd main - Do your thing.
- May need to push to upstream, e.g.,
git push --set-upstream origin main
git log --graph --onlinea. Create New branch: git branch <new_branch>
b. Go into New Branch: git switch <branch_name> old syntax git checkout <new_branch>
c. Push to github/gitlab: git push --set-upstream origin <new_branch>
- Create Rep on https://github.com
- Create/Push on local machine
git init
git add -A
git commit -m "added new project"
git remote add origin https://github.com/<user>/<repo>.git
git push -u -f origin main- Revert files:
git reset --hard HEAD - Remove new directories:
git clean -fd
git restore <filename>old syntax git checkout -- <filename>
git rm --cached <filename>
git stash list
git stash # saves changes to the top of the stash stack
git stash save "Message to go along changes"
git stash -u # stash untracked files as well
git stash pop # applies and remove from stash list
git stash apply stash@{n} # applies only (keeps in the list)
git restore --source=stash@{n} -- <filepath> # apply a single file from stash@{n}
Use git bisect start etc.
Check git help bisect
git clean -xdf# Cleans all new untracked, files and directoriesgit reset HEAD --hard# reverts all changed files
- Git credentials to
libsecret
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
- Add deploy key or ssh
- Idea: Have private key on the PC and the public key on the github repo.
e.g.
ssh-keygen -t ed25519 -C "fmalassenet@grumpypixel.com" -f .ssh/id_github _fmalassenet_grumpy - Update the
~/.ssh/configwith something like
- Idea: Have private key on the PC and the public key on the github repo.
e.g.
# First GitHub Account (or first repo)
Host github-account1
HostName github.com
User git
IdentityFile ~/.ssh/id_github_account1
IdentitiesOnly yes
# Second GitHub Account (or second repo)
Host github-account2
HostName github.com
User git
IdentityFile ~/.ssh/id_github_account2
IdentitiesOnly yes- Update the remote with
git remote set-url origin git@github-account1:username/repot1.git(github-account1 is defined in the~/.ssh/configfile) - Test if ssh works
ssh -T git@github.com - Example for operative games to update access to
originvia sshgit remote set-url origin git@github-fmalassenet-grumpypixel:Operative-Games/omnichannel-unreal-launcher-python.git - Create a clone
git clone git@github-fmalassenet-grumpypixel:Operative-Games/open-source-llm-conversations.git - Can use the
GIT_SSH_COMMANDlikeGIT_SSH_COMMAND="ssh -i ~/.ssh/id_github_fmalassenet_grumpy" git pull
- Adding:
-
git submodule add <repo-url> <path>, e.g.,git submodule add https://github.com/nvim-lua/kickstart.nvim ./nvim/.config/kickstart -
git submodule initandgit submodule udpdate- Cloning:git clone --recurse-submodules <repo-url>Updating:git submodule update --remote --merge### Subtree (simplest) Adding as a remote:git remote add kickstart https://github.com/nvim-lua/kickstart.nvim.gitandgit fetch kickstar Add substree:git subtree add --prefix=nvim/.config/kickstart kickstart master --squash`
- Commit: standard to the original repo
- Pull update of kickstart:
git fetch kickstartandgit subtree pull --prefix=nvim/.config/kickstart kickstart master --squashResolve conflicts
We generate a secret and public key.
- The secret key is kept on the local machine (typically in
~/.ssh/<deploy_key>) - The public key is included in the git hub repo
-
Generation of public/private keys: - Linux:
ssh-keygen -t ed25519 -C "Deploy key for <Repo>typically save the secrete in~/.ssh/<deploy_key>and the.pubwill be posted ongithub-ssh-add ~/.ssh/<deploy_key> -
Example of configuration with
ssh: - Use~/.ssh/config -
Examples using OperativeGames
- Make sure that the deploy keys have restricted access (See
ssh.md) usingicaclson windows, or600on linux
git clone -b rtapi-playground-zoom -c core.sshCommand="C:\\Windows\\System32\\OpenSSH\\ssh.exe -i D:/DeployKeys/id_deploy_omnichannel-node-js-call-server" git@github.com:Operative-Games/omnichannel-node-js-call-server.git
git clone -c core.sshCommand="C:\\Windows\\System32\\OpenSSH\\ssh.exe -i D:/DeployKeys/id_deploy_omnichannel_email_reader_python" git@github.com:Operative-Games/omnichannel_email_reader_python.git
git clone -c core.sshCommand="C:\\Windows\\System32\\OpenSSH\\ssh.exe -i D:/DeployKeys/id_deploy_omnichannel-unreal-launcher-python" git@github.com:Operative-Games/omnichannel-unreal-launcher-python.git
git clone -c core.sshCommand="C:\\Windows\\System32\\OpenSSH\\ssh.exe -i D:/DeployKeys/id_deploy_server_startup" git@github.com:Operative-Games/server_startup.git- Lightweight:
git tag v1.0.0 - Annotated:
git tag -a v1.0.0 -m "Version 1.0.0 release with more stuff
- Specific tag:
git push origin v1.0.0 - All tags:
git push origin --tags
- fetch/pull last tag:
git fetch --tags - change branch:
git checkout v1.0.0 - Short version:
git checkout $(git describe --tags `git rev-list --tags --max-count=1`) - remote name:
git ls-remote --tags origin - local name:
git describe --tags --abbrev=0
#!/usr/bin/env zsh
repos=(
"/mnt/d/2DA/OperativeGames/unreal-zoom-python"
"/mnt/d/2DA/OperativeGames/unreal-pipeline-scripts"
"/mnt/d/2DA/OperativeGames/aws_secrets_manager"
"/mnt/d/2DA/OperativeGames/character-ai-module"
"/mnt/d/2DA/OperativeGames/eleven-labs-tts-module"
"/mnt/d/2DA/OperativeGames/google-stt-module"
"/mnt/d/2DA/OperativeGames/interruption-module"
"/mnt/d/2DA/OperativeGames/lodge-ai-server"
"/mnt/d/2DA/OperativeGames/og-router"
"/mnt/d/2DA/OperativeGames/omnichannel-Node-js-call-server"
"/mnt/d/2DA/OperativeGames/open-source-llm-conversations"
"/mnt/d/2DA/OperativeGames/scenestream"
"/mnt/d/2DA/OperativeGames/table-read"
"/mnt/d/2DA/OperativeGames/unreal-pipeline-scripts"
"/mnt/d/2DA/OperativeGames/viseme-analysis-module"
"/mnt/d/2DA/OperativeGames/zoom-oauth-manager"
)
base_dir="/mnt/d/2DA/OperativeGames"
pull_repo() {
local repo_path="$1"
local repo_name="${repo_path:t}"
if [[ ! -d "$repo_path/.git" ]]; then
print "❌ $repo_path: Not a git repository"
return 1
fi
print "🔄 Pulling $repo_name..."
cd "$repo_path"
# check for uncommitted
if git diff-index -quiet HEAD -- 2>/dev/null; then
print "⚠️ $repo_name: Has uncommitted changes, skipping"
fi
# Pull with status
if git pull --ff-only; then
print "✅ $repo_name: Updated successfully"
else
print "❌ $repo_name: Pull failed"
fi
}
for repo in "${repos[@]}"; do
pull_repo "$repo"
print "━━━━━━━━━━━━━━━━━━"
done
# for gitdir in "$base_dir"/*/.git(/); do
# print "gidir $gitdir"
# repo="${gitdir:h}"
# pull_repo "$repo"
# print "----"
# done- Create a git token and make sure that it has
git config --global url."https://<user>:<gh_token>@github.com/".insteadOf "https://github.com/"for OperativeGames i have been usingfrancois-grumpyfor<user>