GIT: Difference between revisions
From AWVVO
Jump to navigationJump to search
Created page with "== Show current branch == <syntaxhighlight lang="bash" line highlight="" copy> @echo off for /f "delims=" %%a in ('git rev-parse --abbrev-ref HEAD') do ( set "current_branch=%%a" ) echo Current branch is: %current_branch% </syntaxhighlight> == Create new branch == <syntaxhighlight lang="bash" line highlight="" copy> git checkout -b newbranch </syntaxhighlight>" |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Create SSH key == | |||
<syntaxhighlight lang="bash" copy line highlight="0"> | |||
ssh-keygen -t ed25519 -C "your_email@example.com" | |||
cat ~/.ssh/id_ed25519.pub | |||
# Copy the output and add it to GitHub → Settings → SSH and GPG keys → New SSH key. | |||
</syntaxhighlight> | |||
== Git clone using classic token == | |||
<syntaxhighlight lang="bash" copy line highlight="0"> | |||
git clone --branch BRANCH_NAME https://ghp_TOKEN@github.com/USERNAME/REPO_NAME.git | |||
</syntaxhighlight> | |||
== Show local changes == | |||
<syntaxhighlight lang="bash" copy line highlight="0"> | |||
git diff | |||
</syntaxhighlight> | |||
== Show current branch == | == Show current branch == | ||
<syntaxhighlight lang="bash" line highlight="" copy> | <syntaxhighlight lang="bash" line highlight="" copy> | ||
Line 8: | Line 27: | ||
echo Current branch is: %current_branch% | echo Current branch is: %current_branch% | ||
</syntaxhighlight> | </syntaxhighlight> | ||
To show remote branches in Git, use: | |||
1. List all remote branches: | |||
sh | |||
Kopiëren | |||
Bewerken | |||
git branch -r | |||
2. Show both local and remote branches: | |||
sh | |||
Kopiëren | |||
Bewerken | |||
git branch -a | |||
3. Fetch the latest branches from remote: | |||
sh | |||
Kopiëren | |||
Bewerken | |||
git fetch --all | |||
4. Show detailed info about remote branches: | |||
sh | |||
Kopiëren | |||
Bewerken | |||
git remote show origin | |||
== Create new branch == | == Create new branch == | ||
<syntaxhighlight lang="bash" line highlight="" copy> | <syntaxhighlight lang="bash" line highlight="" copy> | ||
git checkout -b newbranch | git checkout -b newbranch | ||
</syntaxhighlight> | |||
== Clone repo using token == | |||
<syntaxhighlight lang="bash" line highlight="" copy> | |||
git clone https://ghp_ABC123yourtoken@github.com/yourusername/your-repo.git | |||
</syntaxhighlight> | |||
== Add current folder to existing github repo == | |||
<syntaxhighlight lang="bash" line highlight="" copy> | |||
git init | |||
git add . | |||
git commit -m "Initial" | |||
git remote set-url origin git@github.com:<username>/<repo>.git | |||
git branch -M main | |||
git push -u origin main | |||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 08:10, 29 March 2025
Create SSH key
ssh-keygen -t ed25519 -C "your_email@example.com"
cat ~/.ssh/id_ed25519.pub
# Copy the output and add it to GitHub → Settings → SSH and GPG keys → New SSH key.
Git clone using classic token
git clone --branch BRANCH_NAME https://ghp_TOKEN@github.com/USERNAME/REPO_NAME.git
Show local changes
git diff
Show current branch
@echo off
for /f "delims=" %%a in ('git rev-parse --abbrev-ref HEAD') do (
set "current_branch=%%a"
)
echo Current branch is: %current_branch%
To show remote branches in Git, use:
1. List all remote branches: sh Kopiëren Bewerken git branch -r 2. Show both local and remote branches: sh Kopiëren Bewerken git branch -a 3. Fetch the latest branches from remote: sh Kopiëren Bewerken git fetch --all 4. Show detailed info about remote branches: sh Kopiëren Bewerken git remote show origin
Create new branch
git checkout -b newbranch
Clone repo using token
git clone https://ghp_ABC123yourtoken@github.com/yourusername/your-repo.git
Add current folder to existing github repo
git init
git add .
git commit -m "Initial"
git remote set-url origin git@github.com:<username>/<repo>.git
git branch -M main
git push -u origin main