Command line instructions
Git global setup
git config --global user.name "chenh"
git config --global user.email "chenh@.....com"
Create a new repository
git clone http://gitlab......local:18080/chenh/Matlab_static_obj.git
cd Matlab_static_obj
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin http://gitlab......local:18080/chenh/Matlab_static_obj.git
git add .
git commit -m "Initial commit"
git push -u origin master
Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin http://gitlab.......local:18080/chenh/Matlab_static_obj.git
git push -u origin --all
git push -u origin --tags
一个实例,将本地的一个新的代码上传到远程仓库一个分支中。
1、创建一个文件夹,并从远程clone一个主分支的代码,这里主要原因是新的代码不是之前建立的那个origin master代码,如果是可以不需要clone。
git clone http://gitlab......local:18080/intelligent_system/RD_ObjSelect
2、进入到clone的文件夹RD_ObjSelect中,cd RD_ObjSelect.
3、查看远程的仓库
git remote show
4、查看远程仓库的分支情况
git branch -r
5、将新的代码拷贝到当前目录下,如果有同名的文件需要覆盖掉
6、在本地创建分支
git checkout -b add_aeb_mpc_filter_static_object
7、创建完可以查看一下,分支已经切换到add_aeb_mpc_filter_static_object
git branch
8、通过push的方式在远程建立一个分支
git push origin add_aeb_mpc_filter_static_object
可能不对,如何在远程建立一个分支还没不知道???
9、将本地的更新文件添加进分支中
git add .
git commit -v
10、之后将本地的分支提交到远程仓库
git push origin add_aeb_mpc_filter_static_object
11、gitignore
首先在软件目录下创建文件.gitignore,之后在该文件内添加需要忽略的文件夹或者文件,如下:
location_json_image/*
location_json/*
此时是忽略了location_json_image和location_json文件夹下所有的文件。随后先要将该.gitignore文件添加到git上,即
git add .gitignore
之后通过git status可以看到两个文件夹没有添加进需要更新的we文件了。