Initializing and synchronizing a Git repository » History » Version 3

ROQUE, Damien, 01/24/2015 12:47 AM

1 1 ROQUE, Damien
h1. Initializing and synchronizing a Git repository
2 1 ROQUE, Damien
3 3 ROQUE, Damien
This documentation explains how to create a Git repository synchronized with a SourceForge project. For ease of use, we will assume in the following that the project identifier and the repository name are identical : @my_project@.
4 1 ROQUE, Damien
5 3 ROQUE, Damien
h2. Optional: configuring Git user identity
6 3 ROQUE, Damien
7 3 ROQUE, Damien
If you are using Git for the first time, you should first consider setting user related parameters. If already used Git on your user session, you can skip this step.
8 3 ROQUE, Damien
<pre>
9 3 ROQUE, Damien
git config --global user.name <name>
10 3 ROQUE, Damien
git config --global user.email <email>
11 3 ROQUE, Damien
</pre>
12 3 ROQUE, Damien
13 1 ROQUE, Damien
h2. Repository initialization and remote configuration
14 1 ROQUE, Damien
15 1 ROQUE, Damien
Create a new directory named after @my_project@ and initialize a Git structure inside it.
16 1 ROQUE, Damien
<pre>
17 1 ROQUE, Damien
mkdir my_project
18 1 ROQUE, Damien
cd my_project
19 1 ROQUE, Damien
git init
20 1 ROQUE, Damien
</pre>
21 1 ROQUE, Damien
22 1 ROQUE, Damien
Connect the local repository to the remote SourceForge, this links is named @origin@.
23 1 ROQUE, Damien
<pre>
24 1 ROQUE, Damien
git remote add origin https://sourceforge.isae.fr/git/my_project
25 1 ROQUE, Damien
</pre>
26 1 ROQUE, Damien
27 2 ROQUE, Damien
h2. First commit and push to the remote repository
28 1 ROQUE, Damien
29 1 ROQUE, Damien
Create and add a dummy file to the repository (to be adapted to something useful).
30 1 ROQUE, Damien
<pre>
31 1 ROQUE, Damien
echo "This is a test file" > file1.txt
32 1 ROQUE, Damien
git add file1.txt
33 1 ROQUE, Damien
</pre>
34 1 ROQUE, Damien
35 1 ROQUE, Damien
Commit the changes locally and push the changes to the remote repository.
36 1 ROQUE, Damien
<pre>
37 1 ROQUE, Damien
git commit -m "My first commit including a dummy file"
38 1 ROQUE, Damien
git push origin master
39 1 ROQUE, Damien
</pre>
40 1 ROQUE, Damien
Notice that the last instruction can be abbreviated by @git push@ if the remote identifier and branch are set as default.
41 1 ROQUE, Damien
<pre>
42 1 ROQUE, Damien
git push --set-upstream origin master
43 3 ROQUE, Damien
</pre>
44 3 ROQUE, Damien
45 3 ROQUE, Damien
h2. Updating changes from remote users
46 3 ROQUE, Damien
47 3 ROQUE, Damien
If you are collaborating with other users (or using several computers), you can update your local repository thanks to the following instruction.
48 3 ROQUE, Damien
<pre>
49 3 ROQUE, Damien
git pull
50 1 ROQUE, Damien
</pre>