Git notes¶
Using git for version control. Lessons learned.¶
How To¶
- Git tag
- Adding a tag
git tag v1.0
git push origin --tags
- push to github
- Deleting tags
git tag -d v1.0
git push origin :refs/tags/v1.0
- Get all tags including remote tags
git fetch --all --tags --prune
- get all remote tags and remove repos removed by remote.
- Need tags for composer
- Adding a tag
- git worktree Git Worktree
- Create temporary checkout for working on a branch without having to stash data
- Delete local and remote branches
git push -d <remote_name> <branch_name> git branch -d <branch_name>
- Update local list and prune branches
git fetch -p
-p is for prunining
Git Resources¶
- Styleguide for git messages - Udacity Git Styleguide
.gitignore¶
- Resources
- .gitignore templates
- Collection of .gitignore templates
- gitignore.io
- Global .gitignore Stackoverflow 7335420
~/.config/git/ignore
- default locationgit config --global core.excludesfile '~/.gitignore'
- set the location
Git error message. Can’t merge unrelated histories.¶
- Allow unrelated histories StackOverflow Issue
git pull remote branch --allow-unrelated-histories
Git error trying to push when pull seems to work¶
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
git checkout master
* git pull {remote} master --allow-unrelated-histories
* Fix conflicts and commit
* git push {remote} master
Removing sensitive data from git after having committed Removing Sensitive Data - Github¶
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch {path/filename}' --prune-empty --tag-name-filter cat -- --all
git push github --force --all
- Remove the references
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
git reflog expire --expire=now --all
-
git gc --prune=now
-
No guarantee that the data hasn’t been downloaded or forked but at least it’s removed going forward.
Git create empty branch¶
- Create Orphan Branch
- Steps:
git checkout --orphan NEWBRANCH
git rm -rf .
git remote add {name} {git remote branch}
git pull -u {name} {branch}
git push -u {name} {branch}
- Now one have a copy of another branch in working branch.
Github Markdown¶
- Languages for code blocks - highlights.js
- Emoji List - :bowtie Emoji Cheat Sheet
Remote branches not showing on local. Only shows master.¶
git branch -a
show all branchesgit checkout --track remote/branch
- pulls in the remote branch.
Unrelated histories¶
git pull --allow-unrelated-histories
Last update: April 13, 2020 16:50:19