git is a great tool to keep track of code, and sharing it remotly to others in your team. to start go to your app repo cd ~/effingcoolapp
and the run git init
what this will do is start up a embedded git database inside of the directory. This directory is now considered to be a git repositiory ( a collection of data versioned by git ). If you look you can see the database/directory created.. use ls -a
.
use the command git remote add name https://repo.example.com
to add a remote to you repo so now you have easy push and pull access to a remote repo, also in inverse you can do git remote rm name
to remove a branch,
git add adds a file to versioning you can just run git add filename.js
to add the file to versioning. You can also do the inverse and do git rm filename.js
and it will remove the file from version... and the directory. So if you still want that file you should mv
the file and then git rm
it. Remember if you push up sensative data it will still be in the history of git.
one of the most important thing that git does is commiting
. Commiting is the act of making a snapshot of your current code. You can easily do this by git commit -m "adding files"
. I added the flag of -m
which is message, and if you want to a message.
now git is for versioning.. but also sharing so its nice to sync up with remote repos and get newer versions of code. to pull down changes from a remote use the command git pull remoteName branch/name
. this will pull down all branches from a given remote. pull will automatically merge in the code pulled from the branch. If you want something a little less automatic you can run git fetch remoteName
and that will pull down all branches from a remote. Then you can merge in what you like by using git merge remoteName/branch/name
.
now lets say you have a great patch for some bugs, so now lets sync up your local code to the remote repository. So first make sure you commit
everything you want to push up and are in the branch you want to push. Then run git push remoteName branch/name
and that will attempt to push up the code to the server.
lets say you have a file that store all you access keys and passwords to the apis you are using... you wouldnt want those to be in git so you can create this great file called .gitignore
in the root of your directory. This will tell git dont version these files. Heres an example
# NodeJS stuff
node_modules
npm-debug.log
# Enviroment
.env
.DS_store
in this example I excluded four things from the git, these things would be thing that are specific to my enviroment. now if I run git add --all
it will skip over those files
move around notes to go in line with talk, add in small section about cloneing, stash, configuration of email username, maybe caching creds, ssh creation.
good url to clone = > https://github.com/scottmotte/sendgrid-nodejs-example