首先在界面创建仓库,然后进行以下操作
1. Create a new repository
git clone git@gitlab.bj.sensetime.com:xxx.git
cd xxx
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
2. Push an existing folder
cd existing_folder
git init
git remote add origin git@gitlab.bj.sensetime.com:xxx.git
git add -f .
git commit -m "Initial commit"
git push -u origin master
3. Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.bj.sensetime.com:xxx.git
git push -u origin --all
git push -u origin --tags
4. Remove file
cd existing_dir
git rm -r --cached yy.txt
git commit -m 'delete yy.txt'
git push origin master
cd existing_dir
git rm file_name
git commit -m "delete"
git push origin master
5. git add -h
git add -h
usage: git add [options] [--] <filepattern>...
-n, --dry-run dry run
-v, --verbose be verbose
-i, --interactive interactive picking
-p, --patch select hunks interactively
-e, --edit edit current diff and apply
-f, --force allow adding otherwise ignored files
-u, --update update tracked files
-N, --intent-to-add record only the fact that the path will be added later
-A, --all add changes from all tracked and untracked files
--refresh don't add, only refresh the index
--ignore-errors just skip files which cannot be added because of errors
--ignore-missing check if - even missing - files are ignored in dry run
6. 远程仓库迁移
6.1 通过删除远程仓库创建新的仓库进行迁移
$ git remote
origin
$ git remote rename origin old-origin
$ git remote add origin 新仓库地址
$ git remote -v
old-origin https://github.com/test/research-study (fetch)
old-origin https://github.com/test/research-study (push)
origin https://github.com/frontend/research-study (fetch)
origin https://github.com/frontend/research-study (push)
$ git remote remove old-origin
$ git remote -v
origin https://github.com/frontend/research-study (fetch)
origin https://github.com/frontend/research-study (push)
6.2 通过重置远程仓库进行迁移
$ git remote -v
origin https://github.com/test/research-study (fetch)
origin https://github.com/test/research-study (push)
$ git remote set-url origin https://github.com/frontend/research-study
$ git remote -v
origin https://github.com/frontend/research-study (fetch)
origin https://github.com/frontend/research-study (push)
|