创建仓库
mkdir /path/to/your/project
cd /path/to/your/project
git init
git remote add origin https://xxxxx.git
创建你的第一个文件,提交,然后推送到仓库。
git config --global user.email "xx@xx.com"
git config --global user.name "xxx"
echo "bang li" >> contributors.txt
git add contributors.txt
git commit -m 'Initial commit with contributors'
git push -u origin master
常用操作
查询状态
git status
删除一个文件
git rm xxx
删除文件夹及其下所有的文件
git rm xxx -r -f
重命名
git mv fileA fileB
恢复文件的修改
git checkout -- ros_arduino_python/src/ros_arduino_python/arduino_driver.py
分支
查看分支
git branch
切换分支
git checkout test
创建分支
git branch test1
上传分支
git push -u origin test1
下拉分支
git pull origin test1
忽略上传文件
在仓库的根目录下,新建.gitignore 文件,内用如下
*~
*pyc
*.swap
# Object files
*.o
*.ko
*.obj
*.elf
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su