【Git+Source Tree使用教程之一】commit & push

About SourceTree

SourceTree is a powerful Git and Mercurial desktop client for developers on Mac or Windows. In this tutorial, we're using OSX 10.9.5 and SourceTree 2.0.4.

【Git+Source Tree使用教程之一】commit & push_第1张图片  



GitHub

Here is our GitHub repository.

 



Cloning from GitHub

Let's clone the repo:

【Git+Source Tree使用教程之一】commit & push_第2张图片  

【Git+Source Tree使用教程之一】commit & push_第3张图片  



Staged & Unstaged

If we make a new file on our local machine, we'll have "Uncommited" changes:

【Git+Source Tree使用教程之一】commit & push_第4张图片  

We can put the file into staging either by checking "Unstaged files" or:

【Git+Source Tree使用教程之一】commit & push_第5张图片  
【Git+Source Tree使用教程之一】commit & push_第6张图片  



commit to a local repo

Now commit the file in the staging area:

 

If we press "Commit" on the top menu, we get the following:

【Git+Source Tree使用教程之一】commit & push_第7张图片  

Fill in out comment, and the hit "Commit" button:

【Git+Source Tree使用教程之一】commit & push_第8张图片

Now, we can see our local repo is 1 ahead of remote repo (origin/master) 



pushing to GitHub

After adding two more files to our local repo, we want to push to a remote repo:

 

Before we do Push, we need to Pull first, so hit the Pull on the top menu:

【Git+Source Tree使用教程之一】commit & push_第9张图片  

Now, press "Push" on the top menu:

Push3Button.png  
 
【Git+Source Tree使用教程之一】commit & push_第10张图片  

As we can see, now our local and remote repositories are in sync!

 



GitHub after the push

After our push, the GitHub looks like this:





Source Tree Preferences

In this tutorial, we used the preferences as shown below:

【Git+Source Tree使用教程之一】commit & push_第11张图片  
【Git+Source Tree使用教程之一】commit & push_第12张图片  



原文链接: http://www.bogotobogo.com/cplusplus/Git/Git_GitHub_Source_Tree_1_Commit_Push.php

你可能感兴趣的:(git,gitlab,教程,tutorial,SourceTree)