Git Basics!
Git Basics you should know:
Setup
git statusshows the current state of your Git working directory and staging area.git config --listlists the git configurationgit config --global user.name "MyLastname MyFirstname"set config for user namegit config --global user.email "myemail@adress.com"set config for user email
Clone repo
git clone https://myadresscloning a repo stored on Github/Bitbucket/…
Set branch
git checkout <branchname>will change to other branch
Update repo
git add myfilenameadds a change in a file to the staging areagit add directory/.adds changes in all files of a directory to the staging areagit commit -m "this has changed"commit staged changes (add message)git pushpush changes to repo
Troubleshooting
git resetwill unstage all changesgit reset HEAD^to uncommit latest commit, keep file changesgit reset --hard HEAD^to remove latest commit and corresponding file changes- If
git config --listshows some entries you want to delete: usegit config --unset-all <name> git push --forceto make the remote repository match your local repo (attention, your remote repo will be overwritten!)
Written on January 2, 2023