Cheatsheet for Git
Git is a version control system which is useful to magage the projects.
Initial setup
git config --global user.name username
git config --global user.email useremail
git config # to check the configuration
Commands absolute necessary
cd path/to/directory/
git init #to initiate a code from scratch
git clone url # to clone code from github
git add filename # to add to staging area
git add * #add all files to staging area
git commit filename -m "msg" #to take screenshot the current structure from the staging area
git commit -m "msg"
git push origin master
git push origin main
Commands frequently used
git status
git remote add origin urlsomething.git
Other useful commands
git rm filename #remove from staging and working directory
git rm --cached filename #removing only from staging area
git reset HEAD filename #to unstage file
git reset HEAD . #to unstage all files
.gitignore # to ignore updating or indexing ; make this file and add filenames to be ignored.
git branch branchname # to create branch
git checkout branchname # to change directory to branch
git config --get remote.origin.url # to get the github url from the local repository
To do: Read about git merge
https://www.atlassian.com/git/glossary