-
Notifications
You must be signed in to change notification settings - Fork 0
gitAtAMin
holzkohlengrill edited this page Dec 15, 2023
·
8 revisions
Most important and essential git
commands.
git config --global user.name "Marcel"
git config --global user.email "[email protected]"
See also .gitconfig
cd existing_folder
git init # Initialise git "env"
git remote add origin https://github.com/TeamFlowerPower/kb.wiki.git # Add repo URL to remotes
git add . # Add all files
git commit # Commit files to repo
git push -u origin master # Push and set upstream (-> `-u`)
git clone https://github.com/TeamFlowerPower/kb.wiki.git
cd kb.wiki
git add contributors.txt # optional
git commit -m 'Initial commit with contributors'
git push origin master
Command | Description |
---|---|
git log |
Show last commits (+metadata) |
git log --name-status |
Show changed files and their status per commit |
git whatchanged -p or git log -p
|
Show textual diffs of last commit |
git whatchanged |
Show changed files + commit messages |
git diff |
Review changes before commit (show uncommitted changes) |
Command | Description |
---|---|
git reset --soft HEAD~1 |
Throws your last (local) commit away (make sure you're on HEAD) |
git reset --hard HEAD~1 |
Throws your last (local) commit away and reverts all your local changes to the last commit (make sure you're on HEAD) |
git commit --amend |
change your last unpushed commit |
git add ./blah && git commit --amend --no-edit |
Include a file to your last commit (i.e. if you have committed only for one file but forgot another which matches you commit message); --no-edit does not open the editor for editing the commit message |
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License *.
Code (snippets) are licensed under a MIT License *.
* Unless stated otherwise