Notes on Git
Description:
So I have been using git
for awhile now, but I still don’t really know how it works. Here is my initial post with it. Here is some light reading you (or I can do to be more familiar with it):
To Resolve
-
See here for common git workflows
-
Here are different git commands:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
git clone (url) - copies a repo locally git add (flename) - Used to add files to commit. git diff - shows differences git commit -m "message" - actually makes a save git commit -am "message" - adds and commits git status - most used command; shows info about git in current directory git push (repo name if needed) git pull - updates your version merge conflict - correct and commit again git log - shows log of commits git reset --hard <commit> - Reverts back git reset --hard (Repo name like - origin/master) - Reverts back to last pull. git branch <branch name> git checkout <branch name> - switches to that new branch git checkout -b - creates a new branch and moves over to it. git merge <branch_name> - branches that branch with current branch
-
Something I have been fighting with recently is that Vscode ignores linux git settings you set if you have WSL enabled. So I would set the global and local configs like mentioned below and vscode would ignore them. I ended up doing the steps in my Github post and installing GCM which then allowed me to push/pull often without entering credentials.
-
Git has three levels of settings:
system
settings can be found by runninggit config --system --list
- These settings can be found by running:
git config --system --show-origin --list
- These settings can be found by running:
global
settings can be found by runninggit config --global --list
- These settings can be found by running:
git config --global --show-origin --list
- These settings can be found by running:
local
settings can be found by runninggit config --local --list
but the trick here is you HAVE to be inside of any repo folder (any folder you previously rangit init
in) where it stores its settings inside a hidden folder called.git
in a file calledconfig
.- These settings can be found by running:
git config --local --show-origin --list
- These settings can be found by running:
- If you just run
cd
to any folder that is is a git repo and then typegit config -l
orgit config --list
, it will show a mixture of all git settings for that repo.
-
Operations to add,remove, and modify:
- To change something, just type its current name and a new value, for example
git config --local user.email gerry.williams@domain.com
will overwrite whatever used to beuser.email
inside the local repo. - To remove a value completely, type
git config --global --unset help.format
replaceglobal
withsystem
orlocal
as needed. Keep in mind on Windows you will need to run Powershell as administrator to changesystem
git settings since they are located in a system directory. - To add it back, type
git config --global help.format html
. Syntax is essentiallygit config --global|local|system setting.name value
- To change something, just type its current name and a new value, for example
Comments