Git using the Operations Guide and GitHub

Source: Internet
Author: User
Tags diff git commands git mergetool sourcetree


This article records the use of Git to organize the scattered memories together. and describes the use of GitHub.

The use of Git represents a mindset and a situation that, compared to SVN, is not so much a technical difference, but rather a new ecological environment. A kind of open and open source mentality, a kind of technology unceasingly learns and realizes the spirit. A kind of strict requirements of their deep understanding, and constantly seeking attitude.


Git using the How-to guide




Recommended Sites:

Http://rogerdudler.github.io/git-guide/index.zh.html

Http://www.git-scm.com/book/zh


git graphical tools


Sourcetree, such as its name, the source tree, can be convenient for code browsing, submission, merging, compared to the use of GIT commands. can improve productivity.

But Sourcetree's ability to resolve conflicts is weaker. The ability to use Eclipse/idean's merge tool is still not very useful.

The recommended comparison merge tool is beyond Campare. Website address: http://www.scootersoftware.com/download.php, as the name implies. Beyond the comparison. Very powerful compare.

Combined with Git. Able to put conflicting documents. Compared to the latest files in the remote code base. Facilitate conflict resolution.


How to integrate beyond Campare and Git under Mac, such as the following:

1, install beyond Campare 2, and run its menu command "Install command line Tools ...", here, we will be able to input bcomp call it at the command

2. Define Git's comparative merge tool, Vim ~/.gitconfig. Input content:

[diff]        Tool = Bcomp[difftool "Bcomp"]        cmd = \ "/usr/local/bin/bcomp\" \ "$LOCAL \" \ "$REMOTE \" [Difftool]        prompt = false[ Merge]        tool = Bcomp[mergetool]        prompt = False[mergetool "Bcomp"]        cmd = \ "/usr/local/bin/bcomp\" \ "$LOCAL \" \ "$REMOTE \" \ "$BASE \" \ "$MERGED \"

3, git difftool file, you can bring up the GUI. It's very convenient to combine files.

On the right is a conflicting local file (which we want to save), and the left side is used to compare the newest remote branch.

Assuming that only git Difftool is entered, all conflicting files are processed one by one.

4, Git mergetool tool, divided into 5 regions. Local/remote/base (common ancestor), the ability to choose the merge code. The target code.


Ps:

Let's say that sometimes git difftool can't bring up the diff interface. You can try to add a conflict file to the stage and then take it out of the stage.

git Add. git reset HEAD.

git add file name git reset HEAD file name

Delete Remote branch: git push origin:20151110-techoptimize

Delete local branch: Git branch-d 20151110-techoptimize


Reference website:

c=kb_vcs.php ">using Beyond Compare with Version Control Systems

Git-difftool-show changes using common diff tools

Use beyond Compare as the default control tool for the Git mergetool for Mac

The git config command uses

Git view, delete, rename remote branch and tag


git descriptive narrative


Git install: http://git-scm.com/book/en/Getting-Started-Installing-Git

git configuration and use: http://railstutorial-china.org/chapter1.html#section-1-3-1

10-minute git tutorial: http://rogerdudler.github.io/git-guide/index.zh.html http://www.open-open.com/lib/view/ Open1332904495999.html

And SVN will add to each directory. svn files are different, git simply creates a. git directory under the root directory, and all of the GIT management-related content is here, assuming you want to remove the project from Git management and remove the directory.

With Git, it's a good idea to build a. gitignore file in every Git project, to generate: https://www.gitignore.io/, which works the same way as SVN's ignore, for example, for Java projects, We can use. gitignore files such as the following:

*.class# Mobile Tools for Java (J2ME). mtj.tmp/# package Files #*.jar*.war*.ear# Vsan crash logs, see http://www . java.com/en/download/help/error_hotspot.xmlhs_err_pid*# Ignore all LogFiles and tempfiles.. project/*/.project.classpath/*/.classpath.settings/*/.settings/*/.settings/*target/*/target/*/target/*. Ds_store.svn.svn/*.idea.idea/*thumbs.db*.log


Git and GitHub


gitclient:http://msysgit.github.io/, use this client's SSH authentication method such as the following:

    • Ssh-keygen-t rsa-c e-mail
    • C:\Users\puma\.ssh\id_rsa.pub (assuming the Mac system, the folder is:/USERS/PUMA/.SSH), the content is completely copied to Gitserver
    • git clone [email protected]:mall/mall.git

Push to Github:http://railstutorial-china.org/chapter1.html#section-1-3-4

Note: You must first register a github.com account, and if you use SSH for push, you will need to create an SSH key. Need to build repository on GitHub.

For example, we have an account on GitHub: Pumadong. A project has been established below: Cl-privilege, which is able to:

Create a new repository on the command line

Touch readme.md

Git init

git add readme.md

Git commit-m "First commit"

git remote add origin [email protected]:p Umadong/cl-privilege.git

Git push-u Origin Master

Suppose you build a project on GitHub. Set up the Readme.md file, the previous step will prompt the version number problem, cannot push, need to use the following two lines:

(

Git pull Origin Master

Git commit-m "First commit"

)

can also:

Push an existing repository from the command line

git remote add origin [email protected]:p Umadong/cl-privilege.git

Git push-u Origin Master

Now we can see this master branch on GitHub:

Https://github.com/pumadong/cl-privilege

About Git. Under Windows and Mac. There are GUI programs available, below Linux, it seems that only git commands are available.

Suppose that this project, when Eclipse was opened, did not identify git, was able to delete the project and clone it from GitHub: git clone [email protected]:p Umadong/cl-privilege.git


Git and Gitlab


GitHub is very expensive for private. For internal use of the company. Gitlab is usually used.

http://www.gitlab.com/

http://www.uloli.com/p/6sh26/


FAQ


When pulling in eclipse, error: The current branch are not configured for pull No value to key branch.mall_2.8.5.merge found in config

The workaround:

Locate the. git/config file. Add the mall_2.8.5 node to it.

chmod 777 * will cause git to feel that the file has been altered.


Git using the Operations Guide and GitHub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.