Skip to content

Git VCS

Terminal window
curl -o git.tar.gz https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.26.2.tar.gz
Terminal window
git --version

Initialize a local Git repository

Terminal window
git init

clone public repository

Terminal window
git clone [repository-url]

Clone private repository

Terminal window
git clone ssh://git@github.com/[username]/[repository-name].git

Check status

Terminal window
git status

Add a file to the staging area

Terminal window
git add [file-name]

Add all new and changed files to the staging area

Terminal window
git add -A

Commit changes

Terminal window
git commit -m "[commit message]"

Remove a file (or folder)

Terminal window
git rm -r [file-name.txt]

Show current branch

Terminal window
git branch

List of branches

Terminal window
git branch -a

Create a new branch

Terminal window
git branch [branch name]

Delete a branch

Terminal window
git branch -d [branch name]

Delete a branch forcefully

Terminal window
git branch -D [branch name]

Delete a remote branch

Terminal window
git push origin --delete [branch name]

Create a new branch and switch to it

Terminal window
git checkout -b [branch name]

Clone a remote branch and switch to it

Terminal window
git checkout -b [branch name] origin/[branch name]

Rename a local branch

Terminal window
git branch -m [old branch name] [new branch name]

Discard changes to a file

Terminal window
git checkout -- [file_name.txt]

Merge a branch into the active branch

Terminal window
git merge [branch name]

Merge a branch into a target branch

Terminal window
git merge [source branch] [target branch]

Stash changes in a dirty working directory

Terminal window
git stash

Remove all stashed entries

Terminal window
git stash clear

Push a branch to your remote repository

Terminal window
git push origin [branch name]

Push changes to new branch at remote repository

Terminal window
git push -u origin [branch name]

Push changes to remote repository

Terminal window
git push

Delete a remote branch

Terminal window
git push origin --delete [branch name]

Update local repository to the newest commit

Terminal window
git pull

Pull changes from remote repository

Terminal window
git pull origin [branch name]

Add a remote repository

Terminal window
git remote add origin ssh://git@github.com/[username]/[repository-name].git

Set a repository’s origin branch to SSH

Terminal window
git remote set-url origin ssh://git@github.com/[username]/[repository-name].git

View changes

Terminal window
git log

View detailed changes

Terminal window
git log --summary

View changes, briefly

Terminal window
git log --oneline

Preview changes before merging

Terminal window
git diff [source branch] [target branch]

Revert commit changes

Terminal window
git revert commitId

Set globally Username

Terminal window
git config --global user.name "your_username"

Set globally Email id

Terminal window
git config --global user.email "your_email_address@example.com"

Get global config

Terminal window
git config --global --list
Terminal window
sudo dnf install gh
gh auth login
gh repo clone <repository>
Terminal window
mkdir -p /data/gitea
compose.yml
version: '2'
services:
gitea:
image: gitea/gitea:latest
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
volumes:
- /data/gitea:/data
ports:
- "3000:3000"
- "222:22"
restart: always
Terminal window
docker-compose --file compose.yaml up -d

Or

Terminal window
podman compose --file compose.yaml up --detach
Terminal window
cargo binstall --strategies crate-meta-data jj-cli
Terminal window
source <(jj util completion bash)
Terminal window
source <(COMPLETE=bash jj)
Terminal window
jj git clone [repository-url]