Use of this document

This is a study note for using \(git\). More information can be found in: Github-tutorial

1. Start working on a new computer

  1. In OS, open cmd
  2. In cmd, enter the working directory, type.
    cd _wd_
  3. To clone the repository to new computer. in cmd, enter url of the master repository.
    git clone https.//github.com/WeiquanLuo/_yourproject_
  4. In cmd, enter the git repository directory, then start editing.

2. Regular push

  1. check if the local branch is up-to-date with centralized location
    git status
  2. Officially add selected files to repository
    git add file.ext git add -A
  3. Officially save & comment the selected files by committing
    git commit -m "some comments"
  4. Upload the local repository to the centralized location
    git push

3. Regular pull

  1. check if the local branch is up-to-date with centralized location
    git status
  2. Officially update local repository from the centralized location.
    git pull

4. If fail to push, which is caused by conflicting pushes from multiple users

  1. check if the local branch is up-to-date with centralized location
    git status
  2. Officially combine the comflict references by pushing
    git pull
  3. After manually resolving conflicts, continue a Regular push

5. Delete local repository

  1. remove connection to git by deleting hidden .git folder
    rm -rf .git

6. Start new repo

  1. create a new repo on github by clicking on new repo via github account
  2. Create new repo dir
    mkdir repo_directory
  3. cd into repo_directory
    cd repo_directory
  4. initiate a new git repo
    git init
  5. Officially add selected files to repository (tracking)
    git add -A
  6. Commit with comments
    git commit -m "some comments"
  7. remotely add the repo using the github account
    git remote add origin https.//github.com/WeiquanLuo/new_repo
  8. set the remote as upstream.
    git push -u origin master

7. Upload large file

  1. Download and install the Git command line extension for Git Large File Storage (LFS). Once downloaded and installed, set up Git LFS and its respective hooks by running.
    git lfs install
  2. Select the file types you’d like Git LFS to manage, (e.g. xxx = shp)
    git lfs track "*.shp"
  3. Make sure .gitattributes is tracked
    git add .gitattributes
  4. Regular push