User Tools

Site Tools


git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
git [2023/11/30 08:45] skipidargit [2025/08/24 14:25] (current) – [Gitflow Workflow] skipidar
Line 35: Line 35:
  
 {{https://www.atlassian.com/git/images/tutorials/collaborating/comparing-workflows/gitflow-workflow/05.svg?20}} {{https://www.atlassian.com/git/images/tutorials/collaborating/comparing-workflows/gitflow-workflow/05.svg?20}}
 +
 +
 +<code>
 +Default Branch Names:
 +
 +Production Branch (master or main): This branch should always reflect the production-ready state of your project.
 +
 +Development Branch (develop): This is the main branch for all new development. Feature branches are created from develop and merged back into it.
 +
 +
 +Feature Branch Prefix (feature/): For new features.
 +
 +Release Branch Prefix (release/): For preparing a new production release.
 +
 +Hotfix Branch Prefix (hotfix/): For quick fixes to the production branch.
 +
 +Support Branch Prefix (support/): For long-running support branches (less common but available).
 +
 +Version Tag Prefix (v): Used for tagging releases.
 +</code>
 +
 ==== FallPits ==== ==== FallPits ====
   * Use the http / https repository for cloning.   * Use the http / https repository for cloning.
Line 308: Line 329:
  
  
-// first backup your history by copying the branch. +#  first backup your history by copying the branch. 
-// can remove it later+#  can remove it later
 git switch master git switch master
 git branch master_history_2023_11_31 git branch master_history_2023_11_31
Line 317: Line 338:
  
  
-//Checkout as orphan, without history+Checkout as orphan, without history
 git checkout --orphan latest_branch git checkout --orphan latest_branch
  
-//Add all the files+Add all the files
 git add -A git add -A
  
-//Commit the changes+Commit the changes
 git commit -am "commit message" git commit -am "commit message"
  
-//Delete the branch+Delete the branch
 git branch -D master git branch -D master
  
-//Rename the current branch to master+Rename the current branch to master
 git branch -m master git branch -m master
  
-//Finally, force update your repository+Finally, force update your repository
 git push -f origin master git push -f origin master
 +
 +
 +</sxh>
 +
 +
 +
 +
 +==== Deleting branch  =====
 +
 +Delete branch ''latest_branch''
 +
 +<sxh shell>
 +
 +git branch -D latest_branch
 +
 +git push origin --delete latest_branch
 +
 +</sxh>
 +
 +
 +
 +==== Remove unreachable blobs, reduce size of repo  =====
 +
 +''objects/pack'': This folder contains packed object files. Git occasionally compresses objects into packfiles to save space and improve performance.
 +
 +
 +Sometimes in ''objects/pack'' there are blobs collected.
 +Even if you removed the history on the current branch, they might persist blowing up the repo.
 +
 +To clean them up - use the garbage collector.
 +
 +<sxh shell>
 +
 +# This command is used to expire all entries in the reflog that are not reachable from the current commit (i.e., entries that are not part of any branch or tag). The --expire-unreachable=all flag specifies that even unreachable entries (such as commits that were "lost" due to being orphaned or removed by a rebase or reset) should be expired. 
 +# The --all flag ensures that it applies to all branches and tags, not just the current branch.
 +git reflog expire --expire-unreachable=all --all
  
  
  
 +# This command triggers Git's garbage collection process (gc stands for "garbage collect"). The --prune=all flag tells Git to aggressively prune all unreachable objects, including unreferenced commits, blobs, trees, and other data that are not reachable from any branch, tag, or reflog entry. This helps to reclaim disk space by removing unnecessary or dangling objects from the repository.
  
 +git gc --prune=all
 </sxh> </sxh>
git.1701333909.txt.gz · Last modified: by skipidar