Git workflows
Continued from:
https://sites.google.com/site/swtraininglog/unclassified-interesting-tech-material/ideal-git-workflow
- Branching strategy
http://nvie.com/posts/a-successful-git-branching-model/
-- release branch is most useful when multiple release versions have a lifetime (Eg. lts releases)
- Git commands visualised
https://dev.to/lydiahallie/cs-visualized-useful-git-commands-37p1
- useful aliases
- can add this to bashrc OR zshrc
- can may be set them as git aliases
* gitl
- the command: git log --all --graph --online --decorate
- alias gitl="git log --all --graph --decorate --oneline"
- what can be deciphered from the graph
- is a feature
* gitm
- alias gitm="git merge --no-ff --no-commit"
* gitpl
- alias gitpl="git pull --no-ff --no-commit"
-- general workflow when working with others:
## update your own branch to latest code from co-workers
git checkout ft-header-update
git pull --no-ff --no-commit origin ft-header-update # not needed, unless working with someone else
git diff --cached # check if your changes are preserved, and your feature is working
git commit # if the diff is okay
git push origin ft-header-update
## update develop latest code from others
git checkout develop
git pull --ff-only origin develop # update develop to latest code
## update own branch with latest changes from develop
git checkout ft-header-update
git merge --no-ff --no-commit develop
git diff --cached # check if your changes are preserved, and your feature is working
git commit # if diff is okay
git push origin ft-header-update
## useful options
git merge --no-ff --no-commit develop # when merging some code into own code
git pull --ff-only origin develop # when simply updating a branch that you have not worked on
## remove the branches that have been removed from remote
## list branches that have been merged into the current branch.
https://sites.google.com/site/swtraininglog/unclassified-interesting-tech-material/ideal-git-workflow
- Branching strategy
http://nvie.com/posts/a-successful-git-branching-model/
-- release branch is most useful when multiple release versions have a lifetime (Eg. lts releases)
- Git commands visualised
https://dev.to/lydiahallie/cs-visualized-useful-git-commands-37p1
- useful aliases
- can add this to bashrc OR zshrc
- can may be set them as git aliases
* gitl
- the command: git log --all --graph --online --decorate
- alias gitl="git log --all --graph --decorate --oneline"
- what can be deciphered from the graph
- is a feature
* gitm
- alias gitm="git merge --no-ff --no-commit"
* gitpl
- alias gitpl="git pull --no-ff --no-commit"
-- general workflow when working with others:
## update your own branch to latest code from co-workers
git checkout ft-header-update
git pull --no-ff --no-commit origin ft-header-update # not needed, unless working with someone else
git diff --cached # check if your changes are preserved, and your feature is working
git commit # if the diff is okay
git push origin ft-header-update
## update develop latest code from others
git checkout develop
git pull --ff-only origin develop # update develop to latest code
## update own branch with latest changes from develop
git checkout ft-header-update
git merge --no-ff --no-commit develop
git diff --cached # check if your changes are preserved, and your feature is working
git commit # if diff is okay
git push origin ft-header-update
## useful options
git merge --no-ff --no-commit develop # when merging some code into own code
git pull --ff-only origin develop # when simply updating a branch that you have not worked on
## remove the branches that have been removed from remote
git remote prune origin # prunes tracking branches not on the remote.## list branches that have been merged into the current branch.
git branch --merged # git clean up file system
https://git-scm.com/docs/git-clean
https://git-scm.com/docs/git-clean
credits:
https://koukia.ca/how-to-remove-local-untracked-files-from-the-current-git-branch-571c6ce9b6b1
https://koukia.ca/how-to-remove-local-untracked-files-from-the-current-git-branch-571c6ce9b6b1
Quoted:
If you want to see which files will be deleted you can use the -n option before you run the actual command:
git clean -n
Then when you are comfortable (because it will delete the files for real!) use the -f option:
git clean -f
Note the case difference on the X for the two latter commands.
Then when you are comfortable (because it will delete the files for real!) use the -f option:
git clean -f
- To remove directories, run
git clean -f -dorgit clean -fd - To remove ignored files, run
git clean -f -Xorgit clean -fX - To remove ignored and non-ignored files, run
git clean -f -xorgit clean -fx
Here are some more options for you to delete directories, files, ignored and non-ignored files
Note the case difference on the X for the two latter commands.
# git log -- [./full/file/path/filename]
and then use git show to get all the changes..
# git log -p [./path/filename]
- get patches for all changes to the file
# git log --follow -p -- path-to-file
This will show the entire history of the file (including history beyond renames and with diffs for each change).
#
This will show the entire history of the file (including history beyond renames and with diffs for each change).
#
#
git shortlog -ns https://mquettan.medium.com/3-git-commands-you-should-never-use-99f6ec910989
git rebase
git submodule
git filter-branch
Housekeeping:
Good to delete branches that are no longer in use. Generally the merged ones or -- abandoned non-merged ones.
Good to delete branches that are no longer in use. Generally the merged ones or -- abandoned non-merged ones.
- list already merged branches
git branch --merged
- un-merged branches
$ git branch --no-merged
Other interesting commands and snippets listed here:
## restore a file or a folder / path with git
git checkout master -- path/to/the/folder-you-want-to-restore/

Comments
Post a Comment