Difference between revisions of "Typical Git workflow"

From RidgeRun Developer Connection
Jump to: navigation, search
m
m
Line 95: Line 95:
 
</pre>
 
</pre>
  
== 8) Push local master to remote git repostiory<br> ==
+
== 8) Push local master to remote git repostiory<br> ==
 +
 
 +
To send the changes (from the HEAD of your local working copy) to your remote repository, execute
 +
<pre>git push origin master
 +
</pre>

Revision as of 03:32, 12 September 2013

Introduction

Normal workflow is to develop and check in on a branch, then once everything is happy, merge the branch back into the master. 

Local repository consists of three "trees" maintained by git. the first one is your Working Directory which holds the actual files.The second one is the Index which acts as a staging area and finally the HEAD which points to the last commit you've made.

WORKFLOW Diagram

Error creating thumbnail: Unable to save thumbnail to destination

References

https://confluence.atlassian.com/display/STASH/Basic+Git+commands

http://rogerdudler.github.io/git-guide/

http://robert-reiz.com/2011/10/01/git-add-commit-push-pull/

Typical Workflow are as follows

1) get local copy of code
2) create a branch
3) edit files
4) add/commit changes to local machine
5) get back in sync with changes commited by others
6) push branch to remote git repository
7) merge local branch into local master
8) push local master to remote git repostiory


For the TATAPowersed SDK we can set REPO and BRANCH as below:

REPO=git@github.com:RidgeRun/tata-sdk-dm36x
BRANCH=fixed-ip-address

1) Get a local copy of the code

git clone $REPO.git tatasdk

OR

git clone https://github.com/RidgeRun/tata-sdk-dm36x.git tatasdk

Creating the Working copy of the local repository by running the command:

git clone path/to/repository

2) Create a Branch

Branches are used to develop features isolated from each other. The master branch is the "default" branch when you create a repository.
Use other branches for development and merge them back to the master branch upon completion.

Create a new branch named tatasdk1 and switch to it using below command:

git checkout -b tatasdk1

Switch back to master by running the below command:

git checkout master

And delete the branch again:

git branch -d tatasdk1

A Branch is not available to the others unless you push the branch to your remote repository

git push origin <branch>

3) Add Files

4) Add / Commit changes to a Local Machine

You can propose changes (add it to the Index) using

git add <filename> 
git add * 

This is the first step in the basic git workflow. To actually commit these changes use:

git commit -m "Commit message"

Now the file is committed to the HEAD, but not in your remote repository yet.

Pushing Changes:

Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository, execute

git push origin master

Change master to whatever branch you want to push your changes to.

5) Get back in sync with changes commited by others

git pull

6) Push branch to remote git repository

git push origin <branch>

7) Merge local branch into local master

To update your local repository to the newest commit, execute

git pull

This will in fetch and merge remote changes in your working directory.

To merge another branch into your active branch (e.g. master), use

git merge <branch> 

in both cases git tries to auto-merge changes. Unfortunately, this is not always possible and results in conflicts. You are responsible to merge those conflicts manually by editing the files shown by git. After changing, you need to mark them as merged with

git add <filename> 

before merging changes, you can also preview them by using

git diff <source_branch> <target_branch>

8) Push local master to remote git repostiory

To send the changes (from the HEAD of your local working copy) to your remote repository, execute

git push origin master