如何使用GitHub客户端以及进行git打分支、merge代码

前言

  • GitHub客户端是一个非常好用的git客户端管理工具。

一、首先介绍如何使用GitHub Desktop

在这里插入图片描述

下载地址:https://desktop.github.com/

下载后我们要添加自己的本地仓库进行管理:
在这里插入图片描述

1. 如果本地没有git仓库的话选择第一个,直接新建一个git仓库。

2. 如果本地已经有git项目的话,选择第二个,添加本地的项目。

3. 如果要直接从远端clone仓库的话,选择第三个。

操作之后就可以查看自己的git仓库里面的代码状态:
在这里插入图片描述

  • 提交代码:
    在这里插入图片描述

选中一个管理的本地git仓库,如果里面的代码有变动,就会显示改变的代码信息,右面是详情。
提交的话在下面的输入框里面 输入提交人和提交的说明信息 点击commit to master 就可以提交到当前分支。
提交完后记得还要点右上角的fetch orign 将代码推送到远端仓库。

二、打分支

在这里插入图片描述
选择New Branch
在这里插入图片描述

输入分支名称,就成功在当前分支上面打了一个分支了。

接下来我们在这个分支上面写代码,当代码写完之后要合并代码了。

首先切换到要合并到的分支,这里我是用master分支。切换到master,点击merge into current branch。

在这里插入图片描述

在这里插入图片描述

选择要合并的分支,点击下面的merge into master。就完成分支的合并了,是不是特别简!

发布了9 篇原创文章 · 获赞 53 · 访问量 7万+
展开阅读全文

如何从git merge中排除特定的提交(永远)

03-14

<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> 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览