Git

Workflow

Some basic git commands to deal with files, versions, and logs.

Tags

gitdifflogbranchcheckoutpullpushtagremote

Info

Files

.git data pertinent to Git is stored in this file, do not alter it

Status

git status returns verbose info about current branch and modified files that are in staging area and untracked files

git status -sb returns list with prefixes ## current branch , M modified files in staging area , ?? untracked files

Diff

Shows differences between current staged changes and the last committed changes.

git diff shows all repository differences

git diff fileName shows differences for given file

git diff directory shows differences for given directory

Versions

r version

head most recent commit

git diff -r HEAD shows differences between staged changes and most recent commit

git diff -r HEAD somePath/someFile shows differences for given file

Commit

git add someFile places file in staging area

git commit -m 'some message' saves staged changes and adds message

Log

git log history of all commits , space continue , q quit

git log someDirectory history of files added or deleted

git log someDirectory/someFile history of commits for file given

Changelog

Feature Branch Workflow

Local Feature Branch

Local Main Branch

If you need to have newest changes from main branch in addition to feature branch changes.

Delete Feature Branch

After branch has been committed and merged it can be deleted. History is preserved.

Tags

Display

git tag displays all tags

git tag -l -n1 displays one line of msg for each tag

*Add

git tag -a v0.1.0 -m 'initial release' someHash adds tag to given commit

git push origin v0.1.0 pushes tag to remote

git push origin --tags pushes all tags to remote

Local Python Server

Navigate to project root directory

py -m http.server 8000 runs server at localhost:8000

CTRL-c stops server

SSH Keys

ls -al ~/.ssh view existing keys

ssh-keygen -t ed25519 -C githubemail make new keys

eval "$(ssh-agent -s)" turn on agent

ssh-add ~/.ssh/id_ed25519 add new keys

Forked Remote

git remote -v shows current linked repositories

git remote add upstream httpsaddressofrepositorytofork add original repository as upstream , this is the original repository , not the fork of the original repository

git remote -v confirm upstream added

git fetch upstream gets newest changes from upstream

git merge upstream/main merges upstream to local main

git push pushes updated changes to your repository fork

notes navigation

Current URL: /notes/00Git/09-workflow/

total notes 36