Jump to content

Typical Git workflow: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
Line 1: Line 1:
== Introduction  ==
== Introduction  ==


Normal workflow is to develop and check in on a branch, then once everything is happy, merge the branch back into the master.   
The 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. You typically only see the working directory, but as you issue git commands, it is helpful to understand the information used by git.
The 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. You typically only see the working directory, but as you issue git commands, it is helpful to understand the information used by git.


== Workflow Diagram  ==
== Workflow Diagram  ==
Line 35: Line 35:
== Get a local copy of the code  ==
== Get a local copy of the code  ==


First create a working directory (what RidgeRun calls a DEVDIR when using a RidgeRun SDK)
First, create a working directory (what RidgeRun calls a DEVDIR when using a RidgeRun SDK)


<pre>
<pre>
Line 72: Line 72:
git creates a commit (very much like a patch file) based on the files you want added to commit.
git creates a commit (very much like a patch file) based on the files you want added to commit.


First you tell git which files you want part of the commit.  Any changes you have made to those files will be included in the commit.
First, you tell git which files you want part of the commit.  Any changes you have made to those files will be included in the commit.


<pre>
<pre>
Line 90: Line 90:
</pre>  
</pre>  


Now the file is committed to the HEAD of your local repository, but the changes are not part of the repository you cloned.  However, git will not let you push your commits to the remote repository unless changes commited by others to the remote repository are part of your local repository.
Now the file is committed to the HEAD of your local repository, but the changes are not part of the repository you cloned.  However, git will not let you push your commits to the remote repository unless changes committed by others to the remote repository are part of your local repository.
   
   
Another helpful command is to see all the commits on your currently checked out branch
Another helpful command is to see all the commits on your currently checked out branch
Line 106: Line 106:
to install the gitk tool.
to install the gitk tool.


== Get back in sync with changes commited by others ==
== Get back in sync with changes committed by others ==


You first need to get your local master in sync with the remote repository, then merge those changes into your branch.
You first need to get your local master in sync with the remote repository, then merge those changes into your branch.
Line 119: Line 119:
If someone changed a file and pushed that change to the remote repository and you changed the file too in your local repository, then you might need to resolve which changes have priority.  There is lots of information on the Internet on how to do this sometimes complex task.
If someone changed a file and pushed that change to the remote repository and you changed the file too in your local repository, then you might need to resolve which changes have priority.  There is lots of information on the Internet on how to do this sometimes complex task.


== Push branch to remote git repository ==
== Push the branch to remote git repository ==


You can share your branch with other by pushing it to the remote repository
You can share your branch with others by pushing it to the remote repository


<pre>
<pre>
Line 148: Line 148:
</pre>
</pre>


== Push local master to remote git repostiory ==
== Push local master to remote git repository ==


To send the changes (from the HEAD of your local master branch) to your remote repository:
To send the changes (from the HEAD of your local master branch) to your remote repository:
Cookies help us deliver our services. By using our services, you agree to our use of cookies.