Git Basics!
Git Basics you should know:
Setup
git status
shows the current state of your Git working directory and staging area.git config --list
lists 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://myadress
cloning a repo stored on Github/Bitbucket/…
Set branch
git checkout <branchname>
will change to other branch
Update repo
git add myfilename
adds 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 push
push changes to repo
Troubleshooting
git reset
will 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 --list
shows some entries you want to delete: usegit config --unset-all <name>
git push --force
to make the remote repository match your local repo (attention, your remote repo will be overwritten!)
Written on January 2, 2023