What is wrong with my git 1.8.4.2-1? - linux

I have an old Synology DS-106j server where I tried to install git using ipkg command. The installation went smoothly, but git failed to work correctly. I am currently learning how to use git, so I don't know if it is a bug from git with the version I am using or something else is wrong.
What I did was create a new local repository with a specified name, add a new file, commit it, and got an error:
NAS_SERVER> git init Test
Initialized empty Git repository in /root/Test/.git/
NAS_SERVER> ls
Packages.gz git_1.8.4.2-1_powerpc.ipk
Test
NAS_SERVER> cd Test
NAS_SERVER> git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
NAS_SERVER> touch Test.cs
NAS_SERVER> ls
Test.cs
NAS_SERVER> git add *
NAS_SERVER> git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: Test.cs
#
NAS_SERVER> git commit -m "Test"
fatal: 57e2b8c52efba71d84c56bf6f37581686b9061a3 is not a valid object
I thought...maybe I did something wrong, so I used git on Windows OS and try a push. Still an error. Transfer the whole repository to the server and check the status. It seems fine. Try a commit. Still the same result. What worse is that I can't update git version without having to compile it, which I don't even know how to do so. Any suggestion to what might be wrong?

If your goal is to push into a git repo located on the synology disk(s) for backup purposes I'd recommend a different approach which would avoid having to install a rather old git version on the synology box itself (which could lead to problems if/when using a newer git version on the windows machine).
Export a samba share from synology, mount it on windows and use the windows git to create the backup repo (maybe even a bare repo, eventually group shared if you plan to share work with other people). Then push from your working repo into this backup repo - all on the windows box. In this scenario the synology box doesn't need git installed, it just serves files (i.e. its original job).
I'm using such setup but with a linux machine instead of a windows one and with the bare repo on the synology disks exported via NFS instead of Samba.

Related

pushing and pulling from remote git repo works but it is empty on remote server [duplicate]

This question already has answers here:
What's the -practical- difference between a Bare and non-Bare repository?
(11 answers)
Closed 2 years ago.
I have a linux server with ssh and git installed.
I created a folder on the root directory and changed its owner to mike to avoid giving out root passwords to anyone.
sudo mkdir /GitRepos
sudo chown mike:mike /GitRepos
Then I created an empty repo, and set it to bare, otherwise pushing to this repo does not work (I tried!!)
mkdir test.git
cd test.git
git init
git config core.bare true
I then used another machine (Windows) to clone the newly created repo:
git clone ssh://mike#myLinuxServer/GitRepos/test.git
and that worked fine, I got an empty repo as expected.
I added some files and committed the change.
git add .
git commit -m "Initial commit"
git push origin master
Pushing works fine. I even deleted the entire repo from the local machine, and tried to clone it again.
cd ..
rd test /s
git clone ssh://mike#myLinuxServer/GitRepos/test.git
It worked fine and I got all of the files.
When I went to the remote Linux machine, I listed the files inside test.git and found it empty.
Where did the files go?
How can the repo receive pushes and give out files for pulls without storing the files in the repo?
The files are stored in the remote repository's database. You cannot expect that the files themselves appear in the remote repository, in particular not when you declare it as bare.
The way you initialized the bare remote repository is very unusual. You should have done it simply like this:
cd /GitRepos
git init --bare test.git
The repository on the server is considered as a bare repo as you ran git config core.bare true. A more common way to initialize a bare repo is git init --bare test.git or mkdir test.git;cd test.git;git init --bare. The difference between git init test.git;cd test.git;git config core.bare true and git init --bare test.git lies in the directory structure. The former creates the worktree(test.git) and the database(test.git/.git) but forbids the worktree then. The latter creates only the database(test.git), without the worktree from the beginning.
A bare repository does not have an active worktree by default, which means you can't check out files from any revision in a bare repository. Although you can create extra worktrees with git worktree add, it's quite rare and may behave not so well as a non-bare repository with extra worktrees. All the revisions are stored as compressed data in the database. You can use commands to read the data, like git show master or git ls-tree -r master.
otherwise pushing to this repo does not work (I tried!!)
It's partially true. You can't push to a non-bare repository when you try to update a branch which has been checked out in the remote repository. If the branch you try to update is not checked out or does not exist yet, you can push to update or create it. With git config receive.denyCurrentBranch ignore or git config receive.denyCurrentBranch warn, you can even update such branch. But in practice, we always use bare repositories to preserve revision data.

How to add java code from eclipse to git repository

I am on a windows machine and my .java files are stored on my disk (C:\Users\myname\workspace..etc)
I have a git repository set up in a cloud and I SSH to it using putty.
My question is, how do I add the files in my workspace to the repository?
When I do git add filename.java the linux terminal says it cannot find specified file.
So do I some how bring the the copies of the java files into this terminal directory?
Btw I'm using an Atlassian Stash on Amazon Web Services.
Go to current working directory to your local project and run following commands:
Step 1 : Initializes a new Git repository. Until you run this command inside a repository or directory, it’s just a regular folder. Only after you input this does it accept further Git commands.
git init
Step 2 : This does not add new files to your repository. Instead, it brings new files to Git’s attention. After you add files, they’re included in Git’s “snapshots” of the repository.
git add .
Step 3: Check the status of your repository. See which files are inside it, which changes still need to be committed, and which branch of the repository you’re currently working on.
git status
Step 4: Git’s most important command. After you make any sort of change, you input this in order to take a “snapshot” of the repository. Usually it goes git commit -m “Message here.” The -m indicates that the following section of the command should be read as a message.
git commit -m "Committing Files - Message"
Step 5: Add origin to the .gitconfig file.
git remote add origin <url to your git repo.git>
Step 6: Push the changes from your local repository.
git push -u origin master

Git - Syncing a Github repo with a local one?

First off, forgive me if this is a duplicate question. I don't know anything but the basic terminology, and it's difficult to find an answer just using laymen's terms.
I made a project, and I made a repository on Github. I've been able to work with that and upload stuff to it for some time, on Windows. The Github Windows application is nice, but I wish there was a GUI for the Linux git.
I want to be able to download the source for this project, and be able to edit it on my Linux machine, and be able to do git commit -m 'durrhurr' and have it upload it to the master repository.
Forgive me if you've already done most of this:
The first step is to set up your ssh keys if you are trying to go through ssh, if you are going through https you can skip this step. Detailed instructions are provided at https://help.github.com/articles/generating-ssh-keys
The next step is to make a local clone of the repository. Using the command line it will be git clone <url> The url you should be able to find on your github page.
After that you should be able to commit and push over the command line using git commit -am "commit message" and git push
You can use SmartGit for a GUI for git on Linux: http://www.syntevo.com/smartgit/index.html
But learning git first on the command line is generally a good idea:
Below are some basic examples assuming you are only working from the master branch:
Example for starting a local repo based on what you have from github:
git clone https://github.com/sampson-chen/sack.git
To see the status of the repo, do:
git status
Example for syncing your local repo to more recent changes on github:
git pull
Example for adding new or modified files to a "stage" for commit
git add /path/file1 /path/file2
Think of the stage as the files that you explicitly tell git to keep track of for revision control. git will see the all the files in the repo (and changes to tracked files), but it will only do work on the files that you add to a stage to be committed.
Example for committing the files in your "stage"
git commit
Example for pushing your local repo (whatever you have committed to your local repo) to github
git push
What you need to do is clone your git repository. From terminal cd to the directory you want the project in and do
git clone https://github.com/[username]/[repository].git
Remember not to use sudo as you will mess up the remote permissions.
You then need to commit any changes locally, i.e your git commit -m and then you can do.
git push
This will update the remote repository.
Lastly if you need to update your local project cd to the required directory and then:
git pull
To start working on the project in linux, clone the repo to linux machine. Add the ssh public key to github. Add your username and email to git-config.
For GUI you can use gitg.
PS : Get used to git cli, It is worth to spend time on it.

How do I create a Git repo out of dev and live versions of an existing site on my webserver?

Some info:
Running Apache 2.2.3 on CentOS 5.6 64bit (dunno if Apache version is relevant here)
Git is installed
It's a VPS, so I have all the access I need
I have an existing website (located at /home/username/public_html/) and a dev version of the site (at /home/username/dev/) both on the same machine.
I work directly on the dev version (actually working local, but using Sublime Text 2's SFTP plugin to automatically upload on save, so for all intents and purposes, I can be considered to be working directly on the files at /home/username/dev/).
What I would like to do is use Git to push changes from dev to live. Currently I am having to keep track of which files are edited and then FTP or copy them over manually. I want to be able to revert changes if something doesn't go right, things like that.
However, I have never used Git (or any kind of version control) before. I've been googling Git tutorials, but everything I have found assumes something different from my actual setup. The main thing is that most tutorials assume brand new projects. I am terrified of messing up my live site by trying to set up a repo for it.
Anyhow, my question: how can I use my existing folders to create a repo where I can push from /home/username/dev/ to /home/username/public_html/ (or pull vise versa)?
I ended up following this tutorial and it does exactly what I wanted.
Assuming that your live version came from some version of your dev version you could get everything into a git repository with
make a copy of your live code
$ cp -axf /home/username/public_html/ git_repo
putting everything in live under git version control
$ cd git_repo
$ git init
$ git add .
$ git commit -m 'Initial import from live version'
now copy over all files from the dev version and put them on a branch dev in git
$ rm *
$ cp /home/username/dev/* .
$ git checkout -b dev
$ git add .
$ git commit -m 'Initial import from dev version'
After that your live code will be on the master branch in the repository and the dev code in branch dev.
If when you are done you always put everything from dev to live, you could achieve this in git with merging your dev into your master branch (which holds your live code) when you are done.
Your live version could be a clone of that repository from the master branch, and deploying would be just a
$ git pull
there.

Unable to create a bare git repository

My git version is 1.5.0.6.
I want to create a bare git repository called sample.git.
I tried all sorts, but it failed:
Try 1:
Gives a usage statement but no git created
git init --bare sample.git
usage: git-init [--template=<template-directory>] [--shared]
Try 2: (using git-init not git init)
$ git-init --bare sample.git
usage: git-init [--template=<template-directory>] [--shared]
Try 3: Create a directory sample and then run same command, but still same output and git repository not created.
Please help me.
Firstly, upgrade your git. Version 1.5 is positively ancient.
If you can't upgrade, I'd just create a normal git repository, then manually convert it to a bare repo. An ordinary git repo will contain a '.git' directory. This can be your "bare" repo. Rename this directory to whatever you like. (You'll probably want to mv .git ../myrepo.git).
Then you have to tell git that it is a bare repo. Do this by adding bare = true to the config file in the [core] configuration section.

Resources