1.初始化项目
git init
2.建立本地仓库和远程仓库的连接
git remote add origin 远程仓库URL
ps:移除git仓库连接可使用 git remote remove origin
3.将码云上的仓库pull到本地
git pull origin 分支名称
4.创建并切换分支,这里和远程仓库的分支要一致(选择指定推送的分支,使用git branch可以查看分支)
git checkout -b 分支名称
5.将文件加载到暂存区
git add .
ps:add错了可以使用git rm --cached 文件名 删除对应的文件
6.将文件提交到本地仓库(-m 描述信息)
git commit -m "上传说明,资源描述"
7.将本地仓库推送到远程仓库
git push origin 分支名称
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload
$ git init
Initialized empty Git repository in D:/myProject/IJProjects/git-upload/.git/
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git remote add origin https://gitee.com/jiang-bing-yang/myprojects/tree/ewell
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git pull origin ewell
remote: [session-18405e8e] 404 not found!
fatal: repository 'https://gitee.com/jiang-bing-yang/myprojects/tree/ewell/' not found
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git pull origin master
remote: [session-804441a1] 404 not found!
fatal: repository 'https://gitee.com/jiang-bing-yang/myprojects/tree/ewell/' not found
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git init
Reinitialized existing Git repository in D:/myProject/IJProjects/git-upload/.git/
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git remote add origin https://gitee.com/jiang-bing-yang/myprojects/branches/ewell
error: remote origin already exists.
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git remote remove origin
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git remote add origin https://gitee.com/jiang-bing-yang/myprojects/branches/ewell
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git pull origin
remote: [session-ca423186] 404 not found!
fatal: repository 'https://gitee.com/jiang-bing-yang/myprojects/branches/ewell/' not found
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git remote remove origin
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git remote add origin https://gitee.com/jiang-bing-yang/myprojects
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git pull origin ewell
remote: Enumerating objects: 35, done.
remote: Counting objects: 100% (35/35), done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 35 (delta 10), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (35/35), 7.51 MiB | 1.04 MiB/s, done.
From https://gitee.com/jiang-bing-yang/myprojects
* branch ewell -> FETCH_HEAD
* [new branch] ewell -> origin/ewell
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git branch
* master
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (master)
$ git checkout -b ewell
Switched to a new branch 'ewell'
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (ewell)
$ git branch
* ewell
master
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (ewell)
$ git add .
warning: in the working copy of 'ewellMqSdkDemo/EwellMQ/SDKConfig.properties', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'ewellMqSdkDemo/EwellMQ/out/artifacts/EwellMQ_jar/SDKConfig.properties', LF will be replaced by CRLF the next time Git touches it
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (ewell)
$ git commit -m "ewell sdk java demo"
[ewell 1a478cd] ewell sdk java demo
23 files changed, 387 insertions(+)
create mode 100644 ewellMqSdkDemo/EwellMQ/.idea/.gitignore
create mode 100644 ewellMqSdkDemo/EwellMQ/.idea/artifacts/EwellMQ_jar.xml
create mode 100644 ewellMqSdkDemo/EwellMQ/.idea/compiler.xml
create mode 100644 ewellMqSdkDemo/EwellMQ/.idea/encodings.xml
create mode 100644 ewellMqSdkDemo/EwellMQ/.idea/libraries/MQSDK_JAVA.xml
create mode 100644 ewellMqSdkDemo/EwellMQ/.idea/misc.xml
create mode 100644 ewellMqSdkDemo/EwellMQ/.idea/modules.xml
create mode 100644 ewellMqSdkDemo/EwellMQ/.idea/runConfigurations.xml
create mode 100644 ewellMqSdkDemo/EwellMQ/EwellMQ.iml
create mode 100644 ewellMqSdkDemo/EwellMQ/SDKConfig.properties
create mode 100644 ewellMqSdkDemo/EwellMQ/lib/MQSDK_JAVA.jar
create mode 100644 ewellMqSdkDemo/EwellMQ/out/artifacts/EwellMQ_jar/EwellMQ.jar
create mode 100644 ewellMqSdkDemo/EwellMQ/out/artifacts/EwellMQ_jar/SDKConfig.properties
create mode 100644 ewellMqSdkDemo/EwellMQ/out/artifacts/EwellMQ_jar/lib/MQSDK_JAVA.jar
create mode 100644 ewellMqSdkDemo/EwellMQ/out/artifacts/EwellMQ_jar/running.properties
create mode 100644 ewellMqSdkDemo/EwellMQ/out/production/EwellMQ/META-INF/MANIFEST.MF
create mode 100644 ewellMqSdkDemo/EwellMQ/out/production/EwellMQ/com/yjb/test/MyException.class
create mode 100644 ewellMqSdkDemo/EwellMQ/out/production/EwellMQ/com/yjb/test/MyTest$1.class
create mode 100644 ewellMqSdkDemo/EwellMQ/out/production/EwellMQ/com/yjb/test/MyTest.class
create mode 100644 ewellMqSdkDemo/EwellMQ/running.properties
create mode 100644 ewellMqSdkDemo/EwellMQ/src/META-INF/MANIFEST.MF
create mode 100644 ewellMqSdkDemo/EwellMQ/src/com/yjb/test/MyException.java
create mode 100644 ewellMqSdkDemo/EwellMQ/src/com/yjb/test/MyTest.java
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (ewell)
$ git push origin ewell
Enumerating objects: 42, done.
Counting objects: 100% (42/42), done.
Delta compression using up to 8 threads
Compressing objects: 100% (30/30), done.
Writing objects: 100% (41/41), 7.51 MiB | 753.00 KiB/s, done.
Total 41 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.3]
To https://gitee.com/jiang-bing-yang/myprojects
1446d31..1a478cd ewell -> ewell
yjb@yjbcomputer MINGW64 /d/myProject/IJProjects/git-upload (ewell)
$
常用命令
1.从远程仓库克隆项目到本地
git clone 项目地址2.初始化本地仓库.
git init # 创建本地仓库3.本地仓库与远程仓库关联.
git remote add 仓库名 仓库地址 # 仓库名自定义 例如:origin4.查看仓库名.
git remote # 查看远程仓库的仓库名,加-v 查看仓库名和地址5.更改远程仓库地址.
git remote ser-url 仓库名 仓库地址6.将文件添加添加到暂存区.
git add . # . 代表所有,可以指定为具体文件7.将暂存区中的文件提交到本地仓库.
git commit -m "注说明"8.查看所有分支.
git branch # 查看本地分支,加-a查看本地分支和远程分支,结果列表中前面标*标识当前使用分支.9.创建分支.
git branch 分支名称10.切换分支.
git checkout 分支名称11.将本地仓库的文件推到远程仓库.
git push 仓库名 分支名称 # 推送时建议先(pull)更新一下12.将远程仓库更新到本地.
git pull 仓库名 分支名称13.修改远程仓库名称
git remote rename 旧名称 新名称14.查看提交记录
git log15.回滚提交
#Reset会把后面提交的记录直接删掉
git reset --hard commithash # 例如:git reset --hard 7b8bcaa0b02959126b923fe554824fa9df1dfd8716.分支合并到主分支上
git merge 分支名称
常见错误
1.提交缓存区中内容到本地仓库
1.1.报错信息如下:
D:\xx\xx>git commit -m"初始化"*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"to set your account's default identity.
Omit --global to set the identity only in this repository.fatal: unable to auto-detect email address (got 'admin@DESKTOP-NHBTH4U.(none)')
1.2.报错原因:
出现错误的原因是因为无用户信息
1
1.3.解决方案:
# 1.添加你的邮箱
git config --global user.email "xxxx@qq.com"
# 2 添加你的昵称
git config --global user.name "name"2.本地仓库提交至远程仓库时
2.1.报错信息如下:
D:\xxx\xxx>git push origin master
To https://gitee.com/xxx/xxx.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/xxx/xxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.2.2.报错原因:
出现错误的主要原因是gitee中的README.md文件不在本地代码目录中2.3.解决方案:
# 1.合并代码
git pull --rebase origin master
# 2.再次提交
git push origin master
我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看rubyzip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d
我试图在一个项目中使用rake,如果我把所有东西都放到Rakefile中,它会很大并且很难读取/找到东西,所以我试着将每个命名空间放在lib/rake中它自己的文件中,我添加了这个到我的rake文件的顶部:Dir['#{File.dirname(__FILE__)}/lib/rake/*.rake'].map{|f|requiref}它加载文件没问题,但没有任务。我现在只有一个.rake文件作为测试,名为“servers.rake”,它看起来像这样:namespace:serverdotask:testdoputs"test"endend所以当我运行rakeserver:testid时
我的目标是转换表单输入,例如“100兆字节”或“1GB”,并将其转换为我可以存储在数据库中的文件大小(以千字节为单位)。目前,我有这个:defquota_convert@regex=/([0-9]+)(.*)s/@sizes=%w{kilobytemegabytegigabyte}m=self.quota.match(@regex)if@sizes.include?m[2]eval("self.quota=#{m[1]}.#{m[2]}")endend这有效,但前提是输入是倍数(“gigabytes”,而不是“gigabyte”)并且由于使用了eval看起来疯狂不安全。所以,功能正常,
Rails2.3可以选择随时使用RouteSet#add_configuration_file添加更多路由。是否可以在Rails3项目中做同样的事情? 最佳答案 在config/application.rb中:config.paths.config.routes在Rails3.2(也可能是Rails3.1)中,使用:config.paths["config/routes"] 关于ruby-on-rails-Rails3中的多个路由文件,我们在StackOverflow上找到一个类似的问题
对于具有离线功能的智能手机应用程序,我正在为Xml文件创建单向文本同步。我希望我的服务器将增量/差异(例如GNU差异补丁)发送到目标设备。这是计划:Time=0Server:hasversion_1ofXmlfile(~800kiB)Client:hasversion_1ofXmlfile(~800kiB)Time=1Server:hasversion_1andversion_2ofXmlfile(each~800kiB)computesdeltaoftheseversions(=patch)(~10kiB)sendspatchtoClient(~10kiBtransferred)Cl
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta
我正在编写一个包含C扩展的gem。通常当我写一个gem时,我会遵循TDD的过程,我会写一个失败的规范,然后处理代码直到它通过,等等......在“ext/mygem/mygem.c”中我的C扩展和在gemspec的“扩展”中配置的有效extconf.rb,如何运行我的规范并仍然加载我的C扩展?当我更改C代码时,我需要采取哪些步骤来重新编译代码?这可能是个愚蠢的问题,但是从我的gem的开发源代码树中输入“bundleinstall”不会构建任何native扩展。当我手动运行rubyext/mygem/extconf.rb时,我确实得到了一个Makefile(在整个项目的根目录中),然后当
好的,所以我的目标是轻松地将一些数据保存到磁盘以备后用。您如何简单地写入然后读取一个对象?所以如果我有一个简单的类classCattr_accessor:a,:bdefinitialize(a,b)@a,@b=a,bendend所以如果我从中非常快地制作一个objobj=C.new("foo","bar")#justgaveitsomerandomvalues然后我可以把它变成一个kindaidstring=obj.to_s#whichreturns""我终于可以将此字符串打印到文件或其他内容中。我的问题是,我该如何再次将这个id变回一个对象?我知道我可以自己挑选信息并制作一个接受该信
我正在编写一个小脚本来定位aws存储桶中的特定文件,并创建一个临时验证的url以发送给同事。(理想情况下,这将创建类似于在控制台上右键单击存储桶中的文件并复制链接地址的结果)。我研究过回形针,它似乎不符合这个标准,但我可能只是不知道它的全部功能。我尝试了以下方法:defauthenticated_url(file_name,bucket)AWS::S3::S3Object.url_for(file_name,bucket,:secure=>true,:expires=>20*60)end产生这种类型的结果:...-1.amazonaws.com/file_path/file.zip.A