Git
Highlights
Setup (debian)
Installing on Linux - see https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
Configure
Set account default identity
$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
Developer flow
# init git repo
$ git init
# or clone if the repo exists already
$ git clone https://..
# basic dev flow
$ git status
$ git add *
$ git commit -am "commit message"
$ git pull --verbose
$ git remote -v
$ git remote get-url origin
# Repo needs to be created in github first
$ git remote add origin git@github.com:username/reponame.git
$ git config --global pull.rebase false # if not done before
$ git pull origin main --allow-unrelated-histories
$ git branch -M main # rename from master to main, I think!!
$ git push -u origin main
# config
$ git config --global user.name "Mona Lisa"
$ git config -l
$ cat ~/.gitconfig
# branching; see REF-3
$ git branch -[dv] -all
$ git branch <newBranchName>
$ git checkout <newBranchName>
$ git checkout -b <newBranchName>
# making changes in <newBranchName>
$ git checkout main
$ git merge <newBranchName>
$ git branch -d <newBranchName> # delete the branch
Start a new Github repo
Git Credential Manager
Source: - Git Credential Manager - Creating a personal access token
Install
$ cd ~
$ curl -LO https://raw.githubusercontent.com/GitCredentialManager/git-credential-manager/main/src/linux/Packaging.Linux/install-from-source.sh
$ sh ./install-from-source.sh
$ git-credential-manager-core configure
Setup
$ git-credential-manager-core diagnose
$ git config --global credential.credentialStore cache
$ cd ~/projects/<repo_name>
$ git push origin main
// The first time or after cache memory expire
Select an authentication method for 'https://github.com/':
1. Device code (default)
2. Personal access token
option (enter for default): 2
Enter GitHub personal access token for 'https://github.com/'...
Token:
Enumerating objects: 14, done.
Counting objects: 100% (14/14), done.
Delta compression using up to 4 threads
Compressing objects: 100% (10/10), done.
Writing objects: 100% (13/13), 2.49 KiB | 1.25 MiB/s, done.
Total 13 (delta 0), reused 0 (delta 0)
To https://github.com/gabepublic/aws-cdk-py-s3-01.git
68a80cd..6ccb35b main -> main
$
Create SSH Key
RELATED: SETUP > Dev Environments > SSH |
On the Linux host, create the ssh key (public & private)
$ cd ~
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
$ ls -al ~/.ssh
[...]
-rw------- 1 gabe gabe 3434 Aug 7 2023 id_rsa_gcloudex
-rw-r--r-- 1 gabe gabe 744 Aug 7 2023 id_rsa_gcloudex.pub
Add to ssh-agent
$ eval "$(ssh-agent -s)"
Agent pid 5416
$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /home/gabe/.ssh/id_rsa:
Identity added: /home/gabe/.ssh/id_rsa (gcloudex@gmail.com)
$ ssh -T git@github.com
$ git clone git@github.com:<username>/<repo>.git
References:
How to generate keys: http://help.github.com/msysgit-key-setup/
Why keys should be password protected and how to set up ssh-agent: http://help.github.com/working-with-key-passphrases/
Connecting to GitHub with SSH
Source: https://docs.github.com/en/authentication/connecting-to-github-with-ssh
Useful topics:
About SSH
Generating a new SSH key and adding it to the ssh-agent
Adding a new SSH key to your GitHub account
Testing your SSH connection
Topic - for better repo search
Add topic(s) to the repo to enable better search of repositories.
Go to the repository. On the righthand side, About, click the Settings
Add Topics
To search based on topic(s), for example, enter the following to the Github page - "Search or jump to...":
user:<username> topic:docker topic:api
Semantic Versioning
Source: http://semver.org/
Tool for testing Semantic Versioning: https://github.com/npm/node-semver
Gist
Search my own gist: on the "Your gists" page, enter the following to the search box:
user:gabepublic parser
How-to
References
[REF-1] Official Git Documentation; include reference, book, video, and other external links
[REF-2] Learn Git with Bitbucket Cloud; Excellent Tutorials
[REF-3] git - the simple guide;
Last updated