• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Source code management in GIT

An easy way to start with the Free CAD source code is using github. While the official Free CAD Git repository is currently hosted on Sourceforge (see below), we also maintain an automatic mirror of the master branch on this github repository: https://github.com/FreeCAD/FreeCAD_sf_master

You can start simply by using the “fork” button on top of the above page. This will create a copy of the FreeCAD repository on your own github account. The general procedure is as follows:

-Create yourself a github account

-Go to https://github.com/FreeCAD/FreeCAD_sf_master

-Pres the “fork” button

-On your machine, clone your newly created freecad fork

-Do your changes to the code

-Create a new branch

-Checkout to that new branch

-Commit your changes to that new branch

-Push that new branch to your github repo

You can also start normally, without using the “fork” button:

-clone the FreeCAD code with git

-Do your changes to the code

-create a new branch

-Checkout to that new branch

-Commit your changes to that new branch

-Create yourself an account on a public git server (github, gitorious, sourceforge or any other)

-Push your branch to that server

important Note: If you have code you wish to see merged into the FreeCAD source code, please post a note in the pull requests section of the FreeCAD forum.

From Sourceforge

To access a Git repository on sf.net, configure your Git client as follows :

git://git.code.sf.net/p/free-cad/code (read-only)

ssh://USERNAME@git.code.sf.net/p/free-cad/code (read/write)

Interested in mastering Git Training? Enroll now for FREE demo on Git Training.

Access rules

We will give everyone interested in participating write access to the git repository as long as you stay away frommaster branch (tip).

Authentication

The read-only access does not prompt for a password.

The read/write access uses your ssh password or ssh key to authorize your access. To perform write operations, your project administrator must have granted you write access to the repository.

Note: In all examples below, “USERNAME” represents your SourceForge.net user account.

How to clone the repository

You can simply clone your remote repository and get working:

-git clone ssh://USERNAME@git.code.sf.net/p/free-cad/code REPONAME

-cd REPONAME

The first time you try connecting to the free-cad.git.sourceforge.net host, you should see a message similar to the following:

-The authenticity of host ‘git.code.sf.net (216.34.181.91)’ can‘t be established.

-RSA key fingerprint is 86:7b:1b:12:85:35:8a:b7:98:b6:d2:97:5e:96:58:1d.

-Are you sure you want to continue connecting (yes/no)?

Before typing ‘yes’ to accept the host fingerprint, ensure the fingerprint is correct for the host. You can find a listing of SSH host keys in the SSH Host Key Fingerprints list. If you receive a host key warning, please contact the SourceForge.net team.

Setting your git username

Users should commit to their project repository using their SourceForge.net username. If that is not already set globally, you can set it locally for the current Git repository like this:

-git config user.name "YOUR NAME"
-git config user.email "USERNAME@users.sourceforge.net"

You can now use some combination of “git add” and “git commit” commands to create one or more commits in your local repository.

From alternative repositories

The beauty of git is that everybody can clone a project, and start modifying the code. Several frequent collaborators of the FreeCAD project have their own git repository, where they build up their work before it is ready to be included in the official source code, or simply where they experiment new ideas. In certain cases, you might want to clone your Free CAD code from one of these, instead of the official repos, to benefit from the changes their users did.

Be warned, though, that this is at your own risk, and only the two official repositories above are fully guaranteed to work and contain clean code.

It is also possible to attach several remote repositories to a same local Free CAD git code, using the “git remote” command. This is useful to keep in sync with the master code branch, but keep an eye on the work of different developers.

Developing

First of all never develop on the master branch! Create a local branch for development.

Branching

An important feature of Git is that it is extremely easy to work with branches and merge them together. Best practices recommend to create a new branch whenever you want to work on a new feature. Creating a branch is done with:

-git branch myNewBranch
git checkout myNewBranch

or, both operation in one:

git checkout -b myNewBranch

you can always check in which branch you are with:

git branch

Committing

Once you did some work, you commit them with:

git commit -a

Unlike SVN, you need to specifically tell which files to commit (or all with the -a option). Your text editor will open to allow you to write a commit message.

Publishing your work on the sourceforge repository

After done some changes on your local branch and commit it (this means commit locally) you can push your repository to the server. This opens your branch to the public and allows the main developers to review and integrate your branch into master.

git push mybranch

Learn more about Git Interview Questions in this blog post.

Publishing on another repository

Git also allows you to merge branches from more than one repository. If you don’t have write access to the source forge hosted Free CAD Git repository, you can also setup an account on any other free Git host such as git hub or gitorious and tell other people to get your changes from there.

Writing good commit messages

You should try to work in small chunks. If you cannot summarize your changes in one sentence, then it has probably been too long since you have made a commit. It is also important that you have helpful and useful descriptions of your work. For commit messages, FreeCAD has adopted a format mentioned in book Pro Git (see #Further Reading).

-Short (50 chars or less) summary of changes

-More detailed explanatory text, if necessary. Wrap it to about 72

-characters or so. In some contexts, the first line is treated as the

-subject of an email and the rest of the text as the body. The blank

-line separating the summary from the body is critical (unless you omit

-the body entirely); tools like rebase can get confused if you run the two together.

Further paragraphs come after blank lines.  

Bullet points are okay, too

Typically a hyphen or asterisk is used for the bullet, preceded by a

single space, with blank lines in between, but conventions vary here

If you are doing a lot of related work, it has been suggested here that one should make as many commits large or small as makes sense for what you are working on using the short one sentence commit messages. When you want to merge, do a git log master. BRANCH and use the output as a basis for your quality commit message. Then when you merge to master use the –squash option and commit with your quality commit message. This will allow you to be very liberal with your commits and help to provide a good level of detail in commit messages without so many distinct descriptions.

For an Indepth knowledge on Git, click on below

Summary
Review Date
Reviewed Item
Source code management in GIT
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Source code management in GIT"

Leave a Message

Your email address will not be published. Required fields are marked *

Site Disclaimer, Copyright © 2016 - All Rights Reserved.