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
本文详细介绍了使用Git进行版本控制的基本流程,包括初始化本地仓库,建立远程连接,拉取和切换远程分支,提交和推送代码,以及创建.gitignore文件的步骤。适合初学者参考。
6434

被折叠的 条评论
为什么被折叠?



