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:
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.
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 ( email@example.com ).
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 pushwill 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.
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.
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
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:
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.
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=2gIf 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.