Adding files to Gitlab repository

Hi,

I am trying to upload an android program to a repository on Gitlab. The problem is that I can’t do it because when I type git status I watch the message:

On branch master
nothing to commit, working directory clean

Then I type git add .

And no messages here

But after typing git status again I should watch the changes but I only see the same message.

What I modified is not code, is only the addition of images in several directories.
The directory of my computer is master branch,

How can I upload the new changes?

Thanks.

“Working directory clean”
That means there are no changes, or your changes have already been committed.
Some things to check:

  1. Is there a .gitignore file in the directory? If so, check if it’s stopping the changes from being tracked, perhaps there’s a line which excludes the images directory? (You might need to show hidden files to see the .gitignore file).
  2. Have you tried “git log”? It should show you what your most recent commits were. Maybe you’ve already committed the changes but they haven’t yet been pushed to Gitlab?

Typing “git add” when there are no changes won’t do anything.

The process is:

  1. Make your changes
  2. Run git status to see what’s changed
  3. Run git add to add your changes
  4. Run git commit to create a commit with your changes
  5. Run git push origin to push your changes to Gitlab (depending how you have it setup)

If you’re new to Git you may want to install a Git client (such as SourceTree, Git Tower, GitKraken, or one of the many open source clients out there).

Hope this has helped!

Thanks for answering. I typed git log and I watched the commits I did. I also changed an xml file of an activity. When I typed git push -u origin master I watched the following:

[master 64bd7e5] App con icono GF y layout con sp en los textos
13 files changed, 51 insertions(+), 2172 deletions(-)
delete mode 100644 .idea/vcs.xml
**create mode 100644 GlobalFlow.git/objects/pack/pack-daf33ba3497262112ef998829f55f4bfe971f191.idx
create mode 100644 GlobalFlow.git/objects/pack/pack-daf33ba3497262112ef998829f55f4bfe971f191.pack
delete mode 100644 app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml
root@debian:/home/alex/GlobalFlow# git push -u origin master
Counting objects: 34, done.
Compressing objects: 100% (29/29), done.
Writing objects: 100% (34/34), 7.40 MiB | 11.42 MiB/s, done.
Total 34 (delta 18), reused 0 (delta 0)
To GlobalFlow.git
**8e8b908…64bd7e5 master → master
Branch master set up to track remote branch master from origin.

But when I login Gitlab I didn’t watch the latest commit.

I typed git push -u origin master again and the message I watched is:

Branch master set up to track remote branch master from origin.
Everything up-to-date

How can I upload the changes to repository?

Thanks

Hmm, something looks wrong there.
If you open the file .git/config, it should show what your origin URL is.
For example:

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = git@gitlab.com:user/repository.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master

Do you have a remote called “origin”? And is the URL set to Gitlab?

If not, that’s why it’s not updating on Gitlab. You may be pushing it to another folder or a local URL instead of Gitlab.com

Another possibility is that it’s listed as “remote gitlab” (or some other name). In that case, you can just run:

git push -u gitlab master

(Replace ‘gitlab’ with whatever the remote is called)

Yes. I have a remote called “origin”. Here is my .git/config file:

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote “origin”]
url = GlobalFlow.git
fetch = +refs/heads/:refs/remotes/origin/
[branch “master”]
remote = origin
merge = refs/heads/master

In the URL there isn’t any user and any mention to Giltlab, but there is a repository that git can find.

Now it makes sense!
Your origin URL isn’t Gitlab, it’s a folder called “GlobalFlow.git”.
So whenever you git push -u origin master, it’s actually just writing to a local folder.

There are two things you need to do:

  1. Delete the GlobalFlow.git folder, you only need the .git folder
  2. Change the origin URL to “git@gitlab.com:axmug/globalflow.git” (or whatever your Gitlab repository URL is)

You should then be able to git push to Gitlab, assuming there are no password or SSH key issues.

The other big problem you’ve got here, is that you accidentally committed your Globalflow.git directory into your repository. It’s like an infinite loop of commits. You definitely need to delete that. It’s like zipping a folder and then placing the zipped folder inside a copy of itself.
That’s why in your commit message it says:
create mode 100644 GlobalFlow.git/objects/pack/pack-daf33ba3497262112ef998829f55f4bfe971f191.idx

At this point it may even be best to create a new repository and paste your files back into it (a fresh commit), because your .git folder would now contain a copy of itself and it’s going to waste space.

Thanks for answering. Finally I decided to delete the project and create it another one with the same name. The problem is that I can’t to upload the new files. I followed the gitlab instructions but in the last step I watched the message:

fatal: git@gitlab.com/globalflow.git does not appear to be a git repository
fatal: could not read from remote repository

Please make sure you have the correct access rights and the repository exists.

I typed the following:

git init
git remote add origin git@gitlab.com:GbFlow/GlobalFlow.git
git add .
git commit 
git push -u origin master

After typing the push I watched the error.
What I want to do is to upload several files that are in my computer to the new repository I just created.

Thanks.

I tried another way to upload files in the repository. I tried to clone it. After typing the following:

git clone git@gitlab.com:GbFlow/GlobalFlow.git

I watched the message

Cloning into ‘GlobalFlow’…
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I checked if the connection is in the right server and I typed:

ssh -vT git@gitlab.com

And I watched no connection:

OpenSSH_6.7p1 Debian-5+deb8u3, OpenSSL 1.0.1t 3 May 2016
debug1: Reading configuration data /etc/ssh/ssh_config
*debug1: /etc/ssh/ssh_config line 19: Applying options for ***
debug1: Connecting to gitlab.com [52.167.219.168] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Debian-5+deb8u3
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH compat 0x04000000

debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr umac-64-etm@openssh.com none
debug1: kex: client->server aes128-ctr umac-64-etm@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA key_server
debug1: Host ‘gitlab.com’ is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: root@debian
debug1: Authentications that can continue: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

I typed ssh-add -l and I watched a key.

How can I clone the repository that is empty?

Thanks.

I fixed the problem. Finally I uploaded the files via https instead of ssh.

Thanks.

2 Likes