git使用

设置global config

git config --global user.name "username"
git config --global user.email "[email protected]"

创建一个新的repository

git clone ssh://[email protected]:222/username/git_test.git
cd git_test
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

将已有的文件上传到git

cd existing_folder
git init
git remote add origin ssh://[email protected]:222/username/git_test.git
git add .
git commit -m "Initial commit"
git push -u origin master

将已有的repository上传到git

cd existing_repo
git remote rename origin old-origin
git remote add origin ssh://[email protected]:222/username/git_test.git
git push -u origin --all
git push -u origin --tags

误删除本地.git文件夹,可以重新建立连接

git init
git remote add origin ssh://[email protected]:222/username/git_test.git
git pull origin master
git add .
git commit -m "1"
git push -u origin master

删除远程git仓库的文件/文件夹

// 删除文件
git rm --cached state_car_frame_rect.cpp 
// 删除文件夹
git rm -r --cached tmp
git commit -m "delete"
git push -u origin master

或者

  1. 进入 Projects ->Your projects
  2. 点击进入你要删除的仓库名称 -> 左侧 Settings
  3. 鼠标滚动到最下面,找到Advanced 点击 Expand
  4. 鼠标滚动到最下面,找到Remove project 点击 Remove project
  5. 在弹出的窗口中,输入并确认想要删除的仓库名称,点击 Confirm

git使用_第1张图片

你可能感兴趣的:(Linux,c++,git)