移动前Pro1目录结构为:文件Pro1.txt、文件Pro123、文件、文件夹pro1dir/,项目 Pro2类似。


cd Pro1

mkdir Pro1
cd Pro1
vi pro1.txt 输入描述信息(move Pro1 to new dir)
如果时github网页创建新文件,则create new file》文件名框中输入文件夹名Pro1/(有个斜杠),在输入文件名即可。
# 移动所有文件(夹)到新文件夹Pro1
cd ..
mv Pro123 pro1dir/ Pro1

# 将文件的修改、删除、新建添加到暂存区
(注意区别:git add -u:将文件的修改、文件的删除,添加到暂存区;git add .:将文件的修改,文件的新建,添加到暂存区)
git add -A
git status
git commit -m "move Pro1 all files to new dir"
git push (可能会输入用户名密码)

# 将新项目添加到旧项目中
# 校验是否添加成功
$ git remote -v
Pro2 (fetch)
Pro2 (push)
origin (fetch)
origin (push)
# 获取新项目内容
git fetch Pro2
# 合并新项目Pro2到本地项目Pro1
git merge Pro2/master
Note 如果报错:fatal: refusing to merge unrelated histories
git merge Pro2/master --allow-unrelated-histories
会提示你输入merge信息:比如输入:mergee Pro2 to Pro1






【 CSDN 】

Life is all about choices! 

已标记关键词 清除标记
<div class="post-text" itemprop="text"> <p>I'm developing some web application (php, codeigniter). Today a time to push it to github has come, but I've encountered an issue I can't manage.</p> <p>I've got 2 branches:</p> <ul> <li>master - this branch should be used for github pushing, does not contain credentials or any other sensitive data (just public code)</li> <li>dev - this is master's child, used for development, does contain credentials (of my private app instantion)</li> </ul> <p>By credentials I mean: database login, password, host, user; oauth services id / secrets; encryption_key. Credentials are stored in 2 separated files within /application/config folder.</p> <p>The idea is that I'll make all changes on dev, than merge dev into master, and pull master content to github (but master can't contain my private credentials).</p> <p><strong>This is what I've done till now:</strong></p> <ol> <li>Removed all credentials from /application/config/config.php and /applications/config/database.php (as I don't want them to be public on github) they've become an empty strings like: $db['default']['hostname'] = '';</li> <li>Started git repository and made an initial commit - the default branch that was created is named 'master'</li> <li>Pulled master into github</li> </ol> <p>And it's pretty cool till now - I've got my project code on github with no credentials within. Next I need to make some changes in my project, so I:</p> <ol> <li>Created new branch 'dev'</li> <li>Stored my credentials into dev, and make a commit - I need dev instantion to have credentials as I'm uploading this to ftp server every time I change something in the code (I don't use local LAMP or anything like this in this project)</li> </ol> <p>So now I need to make some change in dev, upload it and pull to github so I:</p> <ol> <li>Make an change on dev (let's say add new feature)</li> <li>Checkout to master</li> <li>Merge dev into master.</li> </ol> <p><strong>What I expected to happen:</strong> Git will ask me which version of configs should be used in 'master' as it is different in both branches. I will use diff to chose a 'master' verion of files (which does not contain credentials). Git will remember my choice, and in the future I will not have to chose again when I'll merge dev into master. Git works like this on one of my other projects, where dev is a master branch and instantions are it's children (In this case dev is a child and I merge child into parent).</p> <p><strong>What happened:</strong> Git just copied credentials from dev to master, did not ask me about that. So now my master branch is 'tainted' by credentials and I can't push it to github anymore.</p> <p><strong>My questions are:</strong></p> <ol> <li>Why is that happening, how can I avoid this?</li> <li>Is there any other (better?) way to handle that kind of issue.</li> </ol> <p>Please let me know if anything is unclear, any help will be appreciated.</p> </div>
©️2020 CSDN 皮肤主题: 程序猿惹谁了 设计师:上身试试 返回首页