Git and Github tutorial
Create local repository
change to working directory
git init
: create a new local repositarygit status
: see status of the working directory, files cached and files not cached
issue
: Working directory clean,
1. No changes happen in the existing files;
2. No new files are added to the working directorygit add 'NameOfAFile'
: cache the changes in staginggit commit -m 'CommitNote'
: to commit cached changes
Push to and pull from the remote repository
create remote empty repository on Github website
git remote add origin 'https://------.git'
: add the remote repository to local commputer. ‘origin’ is your name of the repositorygit push origin master
: push local commits to branch master of origingit pull origin maste
r: pull remote commits from branch master of origin, typically you change your file on Github website but not reflected in your local repository
Clone repository and edit locally
git config --global user.name "Your name"
git config --global user.email "Your email"
: define the authorgit clone 'https://------.git'
: download remote repository to local computergit remote add origin 'https://------.git'
git push origin master
git pull origin master
Merge repository with a dupicate one locally
git remote add origin 'original repository'
git remote add duplicate 'duplicate repository'
: add remotegit branch graphics
: create branch graphics
git checkout graphics
: switch to branch graphics
git pull keeghan graphics
: cache branch graphics of keeghan to local computer
git checkout master
: switch to master
git merge graphics
: merge branch master with branch graphics, conflicts handled beforehand.Of course you can finish merging in Github interface
Two separete ways of working on Github
Contribute to a repository
1. Fork a repository under your own account
2. Pull from and push to remote repository, work locally
3. Pull request to the original repositoryMerge a repository into yours
1. Create your repository
2. Pull in a repository
3. Merge into yours
4. Push to your remote repository