# ____ ___ _____
# / ___|_ _|_ _|
# | | _ | | | |
# | |_| || | | |
# \____|___| |_|
#
First and foremost git is a version control system, and it is the most popular version control system in use today. Git can do a lot of things for you, and has an intuitive command structure to allow this. Git would not be as popular as it is today, if it were not for the site Github. Which allows anyone to host and share software source code for free.
Below are a few examples on how to use git that are not often encountered.
A pull request is how another user can contribute code to a repository they are not the creator of. This proceess can be performed completely remotely from the command line, but for our purposes will be performed using both the command line and a browser with Github.
git clone https://github.com/USERNAME/REPOSITORY
git add . && git commit -am 'some message about the commit'
git clone --mirror $REPO
java -jar BFG.jar -rt $SENSITIVE_DATA_FILE.txt --private $REPO_NAME
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push
This is a small script that should perform everything needed to remove git lfs from the repository. Unfortunately, it will also uninstall git-lfs from your system, but it can be easily installed again.
#!/usr/bin/env bash
git add .
git commit -am 'preparing for lfs uninstall' && git push
git lfs pull -all
git lfs uninstall
git lfs ls-files | cut -f 3 -d ' ' | xargs git rm --cached
rm -rf .git/lfs .git/hooks/pre-push .gitattributes
git add . && git commit -am 'removed lfs' && git push
git status
When it comes to removing a submodule from a repository, it is not as easy as simply removing the submodule’s
directory, not is it as easy as removing the modules entry from .gitsubmodule
. There is a method to these
things.
.gitmodules
file.git add .gitmodules
..git/config
.git rm --cached .git/modules/$YOURMODULE
git commit -am 'removed module'
To remove a submodule you need to:
Delete the relevant section from the .gitmodules file.
Stage the .gitmodules changes:
git add .gitmodules
Delete the relevant section from .git/config.
Remove the submodule files from the working tree and index:
git rm --cached path_to_submodule (no trailing slash).
Remove the submodule's .git directory:
rm -rf .git/modules/path_to_submodule
Commit the changes:
git commit -m "Removed submodule <name>"
Delete the now untracked submodule files:
rm -rf path_to_submodule
See also: alternative steps below.
–John Douthat