创建新项目
1、在gitlab上创建项目
右上角有一个 new project
2、填写常规消息
按照你的项目名等等完成这些基础信息的填写
3、完成本地和远程仓库的链接、上传等等
这是创建新的项目成功之后网页上的一些提示的操作。我会忽略掉其中创建README的这一步。
我一般执行的操作如下:
(1)在本地项目根目录下右键打开“git bash here”
(2)依次输入:
git config --global user.name "你的用户名"
git config --global user.email "你的邮箱"
git init
git remote add origin 你刚才建立的项目连接
git add .
git commit
git push -u origin master
4、无关文件的过滤
其实这个时候已经完成了一个项目的代码的提交
但是很多时候本地项目目录下的所有的文件都会被上传到gitlab上,所以一些本地的编译器等等与项目无关的一些文件都上传了,所以需要配置一下在上传的时候不需要的内容,这个时候就需要写一个.gitignore文件,具体如下:
仍然在git bash中输入:
vim .gitigorne
然后在跳出来的新建文件中输入你想要过滤的文件,我大概输入了一下的内容:
# Maven
target/
./target
target/*
*.class
*.ser
*.ec
# IntelliJ Idea
.idea/
out/
*.ipr
*.iws
*.iml
# Eclipse
.classpath
.project
.settings/
.metadata/
# OS X
.DS_Store
通过“wq!”保存之后,接着输入:
git add.
git commit -m "add .gitignore"
git push
大功告成!~
其他老是忘记的东西:
Git global setup
git config --global user.name "xxxx"
git config --global user.email "xxxxxx"
Create a new repository
git clone git@xxxxxx.git
cd dnn4homefeedsrecall
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 git@xxxxxx.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 git@xxxxxx.git
git push -u origin --all
git push -u origin --tag