Mac os install git

Source: Internet
Author: User
Tags svn svn update using git sourcetree

Here is the first introduction to using command-line.
1, download git installer, address; http://git-scm.com/downloads
2, open after download, double-click. PKG Installation
3, open the terminal, use the git--version command to view the installation version, there is a successful installation
/* The following 4.5 commands are automatically included if they have already been created using BitBucket */
4, create a global user name
git config--global user.name "first_name last_name"
5, create a global mailbox
git config--global user.email "[email protected]"
6, if you do not want to enter the remote repository each time the password, enter the following command
Git credential-osxkeychain
------> Wait
git config--global credential.helper osxkeychain
# Set git to use the Osxkeychain credential helper
The installation is complete at this git.

Then introduce the meaning of the git basic command;
Clonecloning a remote repository
InitInitializing the Warehouse
Remoteconnecting to a remote repository
Pullget new data from the remote repository drop-down
Pushupload new or modified files from the local repository to the remote repository
Addadd files or modify files, commit and push before using
Loglog information submitted by the current warehouse
StatusCurrent Warehouse version status
Commitcommit to the current warehouse
Branchbranch commands, related additions and deletions check operation
Checkoutuse the last version of the remote repository to completely overwrite the current warehouse content/Select Branch Branch
DiffCompare version Content
MergeMerge version Content

first, use the git command line

Initialization
Git init
--------->
Copy the warehouse address from the BitBucket
--------->
Add source to remote warehouse address with alias origin
Git remote add Origin https://[email protected]/myaccountname/myrepositoryname.git

Second, create a remote repository on BitBucket
After registration follow the prompts to create, very simple ... Don't repeat it.
See Reference; Https://confluence.atlassian.com/display/BITBUCKET/Bitbucket+Documentation+Home in BitBucket 101 documentation

---------above for the initial creation of--------------gorgeous split line---------------The following is the Operation Repository-------------------

With the remote repository repostiory, we should add code or other files or something.

Here is also the introduction of two;
One, using command-line
Second, use Sourcetree

first, use command-line
After the local directory is linked to the remote repository (clone command), use the following method to manipulate the file.

git add xxx Add or to modify the xxx file
------------------>
git commit-m "Adding repo instructions" submit the xxx file to the local repository version;-M "XXXX"; commit log
------------------>
Git push-u origin master submits xxx and log under the master branch of the Remote repository origin (the alias of the remote Repository repository just created)

second, use Sourcetree
Similar to SVN, the specific process is;
add----Adding files to the index----->commit------submitted to the local warehouse------>push--------uploaded to the remote warehouse--------->

After that, we have modified the deletion of the files in the warehouse.

Ps: Remember that if you do not need to create a separate branch, you should use the git pull command every time you operate on the local warehouse, update the remote repository to local, and prevent conflicts. This is similar to the SVN update.

First introduced here, in fact, the operation of the basic and SVN command-line tools and GUI tools are similar.
The main difference in actual use or distributed development mode is different.

Welcome everyone to add ~

----------------------------------------------------------------------Split Line-------------------------------the following for Git branch. Ming-------------------------------------------------

Branch is the branch, Git compared to SVN, the biggest advantage is the perfect distributed management. Each local repository, which is the warehouse, is equivalent to a local version of the server, based on which we can do a lot of branches, different
Type of development. Branch's directory uniformity makes its management, including the merge, very simple and convenient.

First, introduce the next sourcetree under the branch,
Here to provide a more detailed blog links for everyone to refer to, illustrated, has explained the more detailed, no longer repeat.
Reference Address: http://www.takobear.tw/12/post/2014/02/bear-git-flow-sourcetreegit-flow.html

Second, create branch branch with command-line

Cond......

----------------------------------------------------------------------Split Line-------------------------------the following tips----------- ------------------------------------

1, Git stash command
Speaking of branches, using git to develop more complex projects I think there will be a number of local. If we have an important task that is urgent and need to switch to another branch, we need to commit the current content.
However, if I change the content of the confusion, or other reasons do not want to submit to the warehouse, then we can useStashThe order.
$ git stash
This command means putting the contents of the current workspace into a temporary area, which means that using git status, or the Add commit command, is not valid.
But we protected the scene very well. Next, you can checkout to other branch work.

When you come back, you should reply to the scene. Here is a brief description of a working mechanism of the stash command.
When the stash command is used, the contents of the current work area are pushed into a stack queue, yes, just like Navigationcontroller.
If we were to respond to the scene. There are two options;PopOrApply

PopAs the name implies, the current staging content disappears from the stack queue,ApplyAs with Objectatindex, the staging content still exists in the queue.

when multiple branches are stash by us, the following two commands are used;

git stash list: Displays all the backups in the Git staging stack, which you can use to decide where to restore from.
git stash Clear: Empties the git stack. Using graphical tools such as GITG, you will find out which nodes of the original stash have disappeared.

Ps:Remember, a lot of git status commands, like a good memory than a bad pen. Git helps us make a lot of notes to check and prevent mistakes.

2, let git ignore annoying files that you don't want to trace
One, you can set the entire GIT repository to ignore the files.
$ git config–global core.excludesfile ~/.gitignore_global
$vim ~/.gitignore_global

Then set the file we want to ignore in the. gitignore_global file. For example, add the following
# Mac OS X
*. Ds_store

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/

#git
. gitingore
. gitingore.swp

You can save it later. If you enter Git status, you are still prompted to have unwanted tracked files. Need to clean down
$ git rm--cache xxxxxx for files that you want to ignore

Well, there's no more annoying papers.

Two, you can set the ignore file for a directory individually.
To the directory where you want to ignore the file,
$ vim. Gitignore
Add the name of the rule as above
After saving, exit, it's ready.

Mac os install git

Related Article

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.