# Git and Github **Published by:** [coinvest](https://paragraph.com/@coinvest/) **Published on:** 2024-02-29 **URL:** https://paragraph.com/@coinvest/git-and-github ## Content Commands related to a remote repository:git clone git@github.com:USER-NAME/REPOSITORY-NAME.gitgit push or git push origin main (Both accomplish the same goal in this context)Commands related to the workflow:git add .git commit -m "A message describing what you have done to make this snapshot different"Commands related to checking status or log historygit statusgit logThe basic Git syntax is program | action | destination. For example,git add . is read as git | add | ., where the period represents everything in the current directory;git commit -m "message" is read as git | commit -m | "message"; andgit status is read as git | status | (no destination).Delete commits: git reset --hard HEAD~1 - delete last commit You can also remove up to a specific commit using a commit’s hash, like so: git reset --hard To delete commits from remote, you will need to push your local changes to the remote using the git push command. git push origin HEAD --force Undo commit, but keep changes: git reset --soft HEAD~1 gitk - display git in a desktop window git config --global --list - list git repositories config(username, email) git config --global user.name "" - set global git username git config --global user.email - set global git email address git commit -am "commit" - add files and commit at the same time git add --patch - view file changes since the last commit git log --oneline --graph - log commits one line git checkout "filename" - request the contents of the file in the included commit git checkout HEAD~1 - step back 1 commit git checkout --. - reverse git add . git checkout -b add and switch to a new branch git checkout - move to another branch git merge - merge another branch with the main branch git rebase -> git add . -> git rebase --continue - merge another branch from master branch git rm - delete file and add to stage git checkout main - return to the last commit on the main branch git checkout HEAD~1 -> git checkout -B main - merge the main branch into the current commit git reflog -> git checkout - display all previous logs and reset the desired commit git mv - moving files in git and add to stage git diff HEAD~1 HEAD - display the difference between current status and previous commit git reset --soft HEAD~1 - delete last commit, keeping changes git add *. - add all with this extension git branch -D - delete branch ssh keygen -t rsa -C "" - generate public/private key cat c/users/username/.ssh/id_rsa.pub - copy public key to github -> Your Profile=>Edit Profile=>SSH and GPG Keys git rebase =>git commit -m "commit"=> git push -u - push a new branch to github and follow this branch from local git repo git commit -m " Fixes#" - resolve an issue on github in master branch ## Publication Information - [coinvest](https://paragraph.com/@coinvest/): Publication homepage - [All Posts](https://paragraph.com/@coinvest/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@coinvest): Subscribe to updates ## Optional - [Collect as NFT](https://paragraph.com/@coinvest/git-and-github): Support the author by collecting this post - [View Collectors](https://paragraph.com/@coinvest/git-and-github/collectors): See who has collected this post