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
- In OS, open cmd
- In cmd, enter the working directory, type.
cd _wd_
- To clone the repository to new computer. in cmd, enter url of the master repository.
git clone https.//github.com/WeiquanLuo/_yourproject_
- In cmd, enter the git repository directory, then start editing.
2. Regular push
- check if the local branch is up-to-date with centralized location
git status
- Officially add selected files to repository
git add file.ext
git add -A
- Officially save & comment the selected files by committing
git commit -m "some comments"
- Upload the local repository to the centralized location
git push
3. Regular pull
- check if the local branch is up-to-date with centralized location
git status
- Officially update local repository from the centralized location.
git pull
4. If fail to push, which is caused by conflicting pushes from multiple users
- check if the local branch is up-to-date with centralized location
git status
- Officially combine the comflict references by pushing
git pull
- After manually resolving conflicts, continue a Regular push
5. Delete local repository
- remove connection to git by deleting hidden .git folder
rm -rf .git
6. Start new repo
- create a new repo on github by clicking on new repo via github account
- Create new repo dir
mkdir repo_directory
- cd into repo_directory
cd repo_directory
- initiate a new git repo
git init
- Officially add selected files to repository (tracking)
git add -A
- Commit with comments
git commit -m "some comments"
- remotely add the repo using the github account
git remote add origin https.//github.com/WeiquanLuo/new_repo
- set the remote as upstream.
git push -u origin master
7. Upload large file
- 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
- Select the file types you’d like Git LFS to manage, (e.g. xxx = shp)
git lfs track "*.shp"
- Make sure .gitattributes is tracked
git add .gitattributes
- Regular push