个人项目
- clone the repository //this will copy all our team’s files to a local folder on your computer
- make your edits
- git add . // update all files
- Commit : using - git commit -a -m “message”
- git push
团队项目 learder
-
git branch dev //create a new branch called dev
-
git checkout dev //point to the new branch dev
-
git checkout master
-
git merge dev //first go to master brach and then merge the dev branch into master
-
git branch -d dev //after merge the dev branch, you can delete it if not used any more
团队项目 member
- git pull to get the latest update of other members
- git checkout dev //change the update into dev branch
- git add -u --update //only add the changed file to repository
- git add file_1 file_2 file_3 //add file_1, file_2 and file_3
some issue
git stash
git pull
git stash pop
服务器新建代码直接提交
- github上新建repo
- 已有项目文件夹
git init # 初始化git项目
git add .
git commit -m "initial"
git remote rm origin
gir remote add origin "git@github.com:teletraan/Helmet.git"
git push -u origin master
彻底删除大文件的记录,防止git clone时间太久
- 列出所有仓库中的对象(包括SHA值、大小、路径等),并按照大小降序排列,列出TOP 10
git rev-list --all | xargs -rL1 git ls-tree -r --long | sort -uk3 | sort -rnk4 | head -10
- 根据最大文件的路径 {filepath},修改此文件的commit历史
git filter-branch --tree-filter "rm -f {filepath}" -- --all
- 强制提交到远程分支
git push -f --all
清理git仓库,变成新仓库
1.切换到新的分支
git checkout --orphan latest_branch
- 缓存所有文件(除了.gitignore中声名排除的)
git add -A
- 提交跟踪过的文件(Commit the changes)
git commit -am "commit message"
- 删除master分支(Delete the branch)
git branch -D master
5.重命名当前分支为master(Rename the current branch to master)
git branch -m master
6.提交到远程master分支 (Finally, force update your repository)
git push -f origin master
网友评论