Recent Changes

2021-07-26
2021-03-17
2021-03-08
2021-03-03
2021-01-22
2021-01-21

How to Use Git

Through the use of web interface, you can browse Git repository for commits and files.

If you want to use Git commands and tools to access, load with HTTP and Git protocol (port 9418). Then you can both read and write via HTTP and SSH.

Load Contents from Git Repository

If there's a Git repository in your project, the Git repository will appear on the project's “source code” tab. By clicking that tab, you can browse it via web interface. Also, if you select “source code” - “guide”, you can browse all the repositories set up by the project, and you can find the Git repository from there.

If you want to obtain the source of a certain project by using commands, do as shown below. (caution: If you choose this way to clone, you won't be able to push it to the origin as it is. In a situation where you are the developer, use <loginname>@git.osdn.net:/gitroot/... which appears on “access for developers”.)

git clone git://git.osdn.net/gitroot/<projectname>/<repositoryname>

How to commit to Git Repository

Members of the project have the right to commit to the Git repository.

1 Set up the SSH Environment

SSH hosy key finger prints are bellow:

ProtocolFingerprint
SSH version 2 (RSA)SHA256:uKMD1XyGiRCd6QyzCpvlJ5ME79d939Z1Frdua9uZEUE
MD5:b7:78:67:21:63:ef:c2:a8:af:88:6c:a6:98:a7:06:75
SSH version 2 (EDCSA)SHA256:9K7tpuAFYBPZdA0DhEJGTGbzDU63vXHVYdtgf7sEArc
MD5:1c:3b:fe:2d:67:69:02:85:4b:79:64:c8:b5:bc:1e:9b
SSH version 2 (ED25519)SHA256:Zvhg5QZkdPGUR7tOa+xG3txNwFTZCWpOhJKVMAs8H04
MD5:e9:bb:c8:97:b5:f1:f6:d6:5a:17:a8:ab:65:2e:ed:6b

First, register SSH public key on the “User Settings” page. You can use either of the SSH2 (rsa, edcas, ed25519) keys. Be careful with the length of the key which should fit in a line. Otherwise, the key doesn't get copied correctly.

It will take about a few minutes to enable the registered key.

2. Create a New Git Repository

To create a new Git repository, go to the “Source Code” - “Git Admin” page, from the project menu. Then click on the “Create new Git repository” and enter the following items.

  • Name of the repository
  • Summary

Next, click the “Create new Git repository” button to create a Git repository. It will take about a few minutes.

3. Make Preparation on Local Repository

With your local Git repository, set up an e-mail address. Currently, contributions to Git repository are logged based on the registered e-mail address ( loginname@users.osdn.me ).

git config --global user.email <registered e-mail address>
“--global” option will affect the entire Git environment, so if you intend to register only a certain repository, then go to the directory of that repository and execute without the “--global” option. In that case, it will appear on .git/config to look something like this.
[user]
	email = <loginname>@users.osdn.me

3-1 To Migrate from Other Repository

Before you register what's on other repository to OSDN, create a local repository.

git clone git://<other repository>
If you haven't set up user.email for the “--global” option, then go to that repository and use the command like the one above to set up user.email.

4 Commit to the Git Repository

Now that you're ready, let's contribute to the Git repository you just created.

If you are cloning via SSH, then simply

git push
will send the changes to OSDN.

If you want to clone from another area or send a new content created on the local repository, go to the “source code” - “Guide and History” page to refer to the command examples listed in the “Access designed for developers through the use of SSH” column.

For example, if you are pushing, it would look something like this.

git push <loginname>@git.osdn.net:/gitroot/<projectname>/<repositoryname>

By the way, when the Git repository has just been created (Git repository is empty), there are no branch names registered, so you can not write like the example above. In this case, execute it with “--mirror” option or put a branch name, such as master, to execute.

git push <loginname>@git.osdn.net:/gitroot/<projectname>/<repositoryname> master

4-1 Abbreviate a long Git URL

Once you register a URL, like how it's done below,

git remote add osdn <loginame>@git.osdn.net:/gitroot/<projectname>/<repositoryname>

then from next time, all you need is a short command like the one below.

git push osdn

Migrate from GitHub repository

Migratiion sample from GitHub repository to OSDN project git repos.

The following conditions are assumed for explanation.

  • You already register OSDN project for migration (Eample project name is project_example)
  • You already have local clone of target git repository. (Example local repository path name is /home/foo/GITHUB_REPO1)

Create new git repository on the project

You need empty project git repository. So create the new one. Access to project git repository admin page in the project Source Code menu, then click new repository button on top right of the page for register new git repository.

https://osdn.net/projects/project_example/git/admin/

Please wait a few minutes to be created the repository on the OSDN server.

(Example git repository name is example1)

Check repository access URL

When repository is created, please access repository viewer page to check the git repository access URL

https://osdn.net/projects/project_example/scm/git/example1/

Click SSH button on the top right of the page to show the repository access URL via SSH and copy it.

OSDN git acccess via SSH URL has the following format:

YOUR_ACCOUNT@git.osdn.net:/gitroot/project_example/example1.git

Write to OSDN repository

You can write to the OSDN repository from the local repos with command bellow.

cd /home/foo/GITHUB_REPO1
git push YOUR_ACCOUNT@git.osdn.net:/gitroot/project_example/example1.git

You can push the local repo to OSDN repo. But on this command you should write the access URL itself, it is too long. To solve it, you can add shortcut remote name alias.

git remote add osdn YOUR_ACCOUNT@git.osdn.net:/gitroot/project_example/example1.git

After remote shotrcut alias name is added, you can push to OSDN repo as bellow.

git push osdn

If you do not adjust any settings, the local repository cloned from a remote have origin remote shortcut alias. It is pointed to remote URL of cloned from. And origin remote is set as default remote.

So, If you push without URL or remote shotrcut name git push data to the origin.

If you want to change default remote to OSDN repo, you can use -u option for push to update it.

git push -u osdn

After the command, default remote will be change from origin to osdn remote. You can push to osdn without any options.

git push

Cautions on when you are operating on Windows

When you are using “Git on Msys” on Windows, in this binary package, the below items are set up as the system default.

core.symlinks=false
core.autocrlf=true
color.diff=auto
pack.packsizelimit=2g
If you put “core.autocrlf=true”, the line break code LF gets replaced with CRLF while file hierarchy gets structured from repository object. So if you use LF intentionally, it gets changed during every commit. To disable core.autocrlf, execute the commands below.
git config --system core.autocrlf false
or
git config --system --unset-all core.autocrlf

If you wish to not change the setting for the whole system, use --global instead of --system, or simply delete the option.