ubuntu下git使用总结

来源:互联网 发布:linux上新建weblogic域 编辑:程序博客网 时间:2024/06/05 04:44

Git是一个开源的分布式版本控制系统,Git的读音为/gɪt/,最初是为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件,后来被广泛地用于其他自有软件项目。

git使用方法:

1.下载

sudo apt-get install git


2. 创建仓库(repository)

在要创建仓库的项目的根目录下执行git init


3. 将本地代码上传到github

step1:在github创建仓库,github是图形化界面,并且有各种提示,比较好创建

step2:配置本地的git的用户名和邮箱,执行git config --global user.name "yourname"; git config --global user.email "youremailname.xx.com",yourname为github注册的用户名,youremailname.xx.com为在github注册的邮箱

step3:添加远程仓库,执行git remote add origin git@github.com:yourname/yourRemoteRepo.git,yourname为在github注册的用户名,yourRemoteRepo为在github创建的仓库的名字

step4:更新远程仓库文件到本地,在向github上传代码前,需要先更新github上的代码,否则可能会上传失败,这个道理跟我们使用SVN前要先update是一样的道理。执行git pull yourRemoteRepo master,yourRemoteRepo为在github创建的仓库的名字

step5:添加需要上传的文件,执行git add xxx,xxx为要上传的文件名,可以使用git add ./*上传当前目录(包含子目录)下的所有文件

step6:上传文件,执行git push origin master

step7:确认结果并添加注释,执行 git commit -m "your comment",your comment 为注释内容


4. 查看当前状态

执行git status






0 0