15. GIT and GITHUB
home
Contents
learning reference
- git essential training
- Lynda.com
- published in 2012
- more than 4 million views
Simple lab for Git and GITHUB
- Git and Github are for version control, collaboration, deployment.
- This demos to upload a folder for share in public.
- In the previous section, one folder app4jwt, is used for the lab.
1. create a local repository
- For mac, open the terminal window, navigate to that folder
- enter git init, to create folder .git for git
All the git stuffs are in folder .git
- enter git add . to copy all working area to stage index area
git can be for a very strict operation, it uses 3 tree architecture.
- git commit m "git init for app4jwt 10/04/2017
It copy them from staging to local repository, and start tracking any changes.
- enter git log to verify the commit
2. create a remote repository
- Open a browser, navigate to https://github.com
- login my account with username, and password
- click the button for new repository
- set name to app4jwt
- set description to nodejs app using json web token for auth
- take note of the url https://github.com/peterkao87/app4jwt.git used in the next step.
3. create a connection in local repository
- back to the mac terminal window
- enter git remote to see any connection. The result is none.
- The syntax for add a connection git remote add
- enter git remote add origin https://github.com/peterkao87/app4jwt.git to create a connection
url: is from the previous step
alias: for further references of remote repository.
- enter git remote to verify the add. You'll see origin.
- note: to remove the connection: git remove rm origin
4. push master branch from local repository to remote repository
- still in the mac terminal window
- enter git branch> to find the list of branches.You'll see only one - master.
- syntax: git push -u origin
- enter git push -u origin master
master is the branch name
- The push is done.
5. download for public
- My Gibhub account is for public.
- The contents can be download from https://github.com/peterkao87/app4jwt.git for public.
- click button clone or download
Changes
If the last change in the remote is yours.
- Just update your in your local working area.
- git add .
- git commit m "....."
If the last change in the remote is not yours.
- The process of fetch and merge are needed