GIT and GITHUB


Web Development

Updated Dec 14th, 2021

git is a decentralized version control system
tracks every change made and can revert back
repository on local machine and then you push to a remote repository like github
don’t need internet connection until the push
a commit is a snapshot of your files


basic commands include:

initialize local git repository
add files to index (git init) creates a .git folder in directory as “hidden” file so make sure folder search options are correct
check status of working tree; shows differences
commit changes in index
push to remote repository
pull latest from remote repository
clone repository into a new directory

Link to Windows install (http://git-scm.com/download/win). Comes with gitbash which looks more linuxy and the author uses this over command line. Commands are better than the GUI tools that are available

git bash
commands entered after the prepopulated dollar sign
git –version shows version
create new folder on desktop called myapp
hold control and scroll makes window bigger and or smaller
touch index.html, and touch app.js, creates html and J’s files in the directory
git config –global user.name ‘brandon visokay’
git config –global user.email ‘me@brandonvisokay.com’
git add index.html (adds index to staging area)
git status shows status
git rm –cached index.html removes file from staging area
git add *.html (adds all html files with *universal selector)
git add. (adds all with the period)
git commit (opens Vim editor which can be confusing because if you start to type it doesn’t do anything) (type the letter eye I to go into insert mode so now you can type)(number sign treated as a comment)
in vim editor (erase pound sign in front of “initial commit”, press escape, type :wq
skip edit phase in vim editor by adding -m ‘comments go here’ after git commit.
next up is git ignore, files and folders to exclude when using git add. (add dot)
touch .gitignore, and touch log.txt (creates new file) and open in text editor and add any files (with extension) You would like to ignore (like log.txt)
/foldernamehere to ignore a directory
branches
imagine group of developers working on large project: don’t want entire code based changed
main branch is master branch
git branch branchname
git checkout branchname (sends you to branch)
there’s a lot involved in branches and merging
if you’re working solo you won’t even need branches likely
github.com
free to create account
create new repository
private cost money ($7 a month)
optional is to add readme.md (MD stands for markdown) to display nicely on github
touch readme.md (checkout documentation for md format)
copy remote address from GitHub and paste into gitbash mf
git remote (returns origin)
paste in git push – origin master
GitHub will popup to validate credentials
git push ( to GitHub)

WP deployment using github here.

Advanced Git

Great video here. Watch and rewatch. Corey Schafer has some good tutorials on git.


Top