Skip to content

mzechmeister/git-cheat-sheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 

Repository files navigation

git-cheat-sheet

undo file modification

git reset --hard           # resets all modifactions!
git restore path/to/file   # a single file

undo commit (not pushed)

git reset HEAD~     # modifications will be kept.

undo last pushed commit

git log --oneline
git reset --hard HEAD^     # Use --hard if you don't care about keeping the changes you made
git push -f

modify unpushed commit message

git commit --amend -m "New commit message"

branching

git branch testing      # create a branch   
git checkout testing    # switch the branch
# do stuff
git commit
git pull
git checkout master
git merge testing       # with master 

branch when already modified

git checkout -b testing

This takes the modifications into the new branch (and main will have no modifications anymore).

staging

git stage filename
git pull

git restore --staged <file>

new access rule

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for

From github doc. Once for the whole account:

xclip -selection clipboard < ~/.ssh/id_ed25519.pub

In each repo:

git remote set-url origin [email protected]:mzechmeister/<reponame>
git push

Make sure ssh and not https is used. (Create a token (https://github.com/settings/tokens) and provide the token as "password".)

See also

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published