Pull remote branch
- Create a new empty folder
- Initial
git init
- Create remote connection
git remote add origin https://gitee.com/XXXX.git
- Fetch remote branch to local
git fetch origin branch_name
- Create local branch and swift to this branch
git checkout -b local_branch_name origin/remote_branch_name
- Pull
git pull origin remote_branch_name
Push to remote branch
- git add .
- git commit -m “message”
- git pull origin remote_branch_name
- git push origin remote_branch_name
Create .gitignore before pushing
- touch .gitignore
- enter i to edit .gitignore
Example .gitignore for Vue projects:
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
- Press esc to exit editing mode, enter “:wq” to save.
Note that if there are submissions already, we should remove cache before pushing again, or .gitignore would not be working.
git rm -r --cached .
git add .
git commit -m 'update .gitignore'
git push origin remote_branch_name