I need to share a large git repository (>3GB in total, .git folder is ~1.1GB) as Windows Shared Folder over LAN with my colleagues. But they found it is really slow to clone and push/pull -- i.e. waits ~30min before the clone starts, and suspended ~5min before any push/pull starts.
Does everyone know any methods to reduce the latency or better way to share the repo?
P.S. I don't want to setup a Gitlab because it's too complicated.
Since your git repo is very big, you can bundle the whole git repo or part of commits among your colleagues sharing.
Bundle the whole repo: git bundle create repo.bundle --all
Bundle a branch: git bundle create repo.bundle branchname
Bundle some commits: git bundle create commits.bundle branchname ^commit
For the one who apply the bundled commits to his local repo, he can verify the bundle file by git bundle verify /path/to/bundle/file.
More details, you can refer Git's Little Bundle of Joy and git bundle.
git daemon works really well in this situation. Its performance is good, but lacks of security on Windows Server.
On server side, run the following command:
cd ~/Documents/All-My-Git-Repos/
git daemon --verbose --reuseaddr --export-all --enable=receive-pack --base-path=.
On client side, clone any repo like this:
git clone git://my-git-server-address/repo-folder-name repo-clone-name
While using this on Windows server, the firewall will prompt for permissions on Port 9418, which should be granted.
Related
I need to push my modified new java code to my old git repository in github but I do not have old code in my pc. How to do that?
I had push a code before my github account before. Now I don't have that old code in my pc. How do I pull the project into my pc and after making changes, push again to the same repository?
I do not have much experience in github, so please help me to improve skills on github.
Check your remote first to see where it is pointing to by
$ git remote -v
origin ssh://git#<old-git-url>/<project>.git (fetch)
origin ssh://git#g<old-git-url>/<project>.git (push)
Change the pointing to GitHub
$ git remote set-url origin ssh://git#<github-url>/<project>.git
Now your repo is pointing to Github
Now you can make your changes and then add them and do a commit and finally push to remote branch; say you are on master.
git add <file>
git commit -m <commit message>
git push origin master
I had to do just that and achieved it like this.
Setup. I assume you have a new remote repository with files that may not cause a conflict with the directory you currently have locally.
Git clone from the git repository you need to push to. Just make sure you create a new directory for the cloned code.
Copy the contents of the cloned repository into the local directory that has your current code. Make sure to copy the .git (hidden) file.
cd into your local directory and run git remote -v. You should see the remote repository git address.
git add -A to add whatever change you require and commit it.
Finally git push
You need to make sure that your local repository (the one that is on your computer) is connected to the remote repository (the one that is on the GitHub servers).
After this, you need to add the modified file to the staging area. Say, you have a file test.txt that you have modified, you would add it to the staging area by typing
git add test.txt
After that you would need to commit those changes. You can do that by
git commit -m "commit message"
And that's it, you have now saved those changes and recorded them in the version control. But the changes that you made have only been recorded in your local repository and you would need to push these changes to the remote repository (the GitHub servers). You can do this by
git push origin master
It would take a few seconds (depending on your internet speed and the project file size) to push these changes to the remote servers. Once it's done, you can open that repository on GitHub and see the changes for yourself.
Just to amend this a bit. I believe "master" is now "main" in some instances or platforms. If this answer isn't working for you, try swapping that out. It worked for me.
I'm working for a client who has their own secure git repository, which is only accessible by a VPN connection. My company has its own secure VPN, where our GIT server resides. Some colleagues don't have access to the client's repo and updating our repo is very time-consuming.
I wrote a small sh script that asks us to connect to the client's VPN, and once connected it fetches all relevant repos. The script then asks us to disconnect and connect to our own VPN, after which the script must push the changes.
I'm having trouble with this last part. How can I have git push everything I just fetched? This is not only the typical "develop" and "master" branches but also new branches with unknown names (e.g. newFeature/XXXX, where XXXX is unknown and can change).
Thanks in advance for your help!
See "Set up git to pull and push all branches", which includes, as commented:
git push --all origin
In your case:
git push --all -u
if you add -u once, e.g. git push --all origin -u, tracking is setup and after that you can simply use git push.
I need to have a portable git setup in order to access a git repository in my LAN from a portable HDD, including the computer where the HDD is connected, under Windows. The HDD might be moved from time to time between the computers in my network. I wish to avoid SSH for the moment.
I have installed the portable version of the git, I have made a batch to set the PATH to the requested directories specified in the documentation before running git-bash or git-cmd.
I see it runs, I have made a bare repository, let's say in a path like m:/repo.git. Then, I got stuck as I don't know how to configure the remote in order to do the first push as `git push repo master' from my project path.
I think I should do a 'git remote add repo ' but I fail to set the correct URL or something. I am aware I should change the URL each time the HDD is moved or change the remote.
What are the correct setup steps?
Then, I got stuck as I don't know how to configure the remote in order to do the first push as `git push repo master' from my project path
Let git create that setting for you:
git clone m:/repo.git
cd repo
git --work-tree=..\myproject add .
git commit -m "first commit"
git push
That will import the files of your project in a local repo, which will be able to push back to your bare repo on M:\.
UNC paths are supported too
git.exe clone "d:/dev/SDK" "//comp1/Proj/git/SDK/"
I know this question has probably been asked a few times but I can't find an exact example of what i'm looking to do and for some reason I can't seem to get it to work.
I have a local ruby on rails repo i'm ready to share with another developer, could someone give me a run through(or point me in the right direction) of creating the new repository by PUSHING my local repo up to it?
Thanks
Marc
I would highly recommend bitbucket (Free up to 5 users) as a hosted git service. They have great documentation:
EDIT:
create repo
https://confluence.atlassian.com/display/BITBUCKET/Create+a+repository
push
https://confluence.atlassian.com/display/BITBUCKET/Import+code+from+an+existing+project
If you want to manage your own remote git repo, then
Make a bare clone of the repo
git clone --bare my_git_project my_git_project.git
Copy the bare repo to remote server
scp -r my_git_project.git gituser#remoteserver.com:/opt/git
Then login to the remote server and go to the git folder
ssh gituser#remoteserver.com
cd /opt/git/my_git_project.git
Then run this command
git init --bare --shared
At this point, any user who has ssh access to the remoteserver.com and write permissions on /opt/git/my_git_project.git will also have push access
A software such as Open source GitlabHQ is highly recommended if you wish to manage your own git hosting. Gitlab also has a hosted version gitlab cloud with unlimited free private repos and unlimited collaborators. Of course they also have paid version.
Some time ago I found some code in one Github repo. I downloaded it (did not fork it), started upgrading it and when I was happy with the result, I used Heroku as a host. So now the code lives on my computer and Heroku. How could I push it to my Github account, but also give the original author of the project some credit for it (showing on my Github that I actually forked it)?
Okay, so I actually figured it out already!
First, create a new repository on github, let's name it github-project.
git clone git#heroku.com:<heroku-project>.git
cd <heroku-project>
git remote rm origin
git remote add github https://github.com/<github-username>/<github-project>
git pull github master
Now you'll probably see some conflicts. If you want to preserve all your changes, just add them all.
git add .
git commit -m "some message"
git push github master
This is quite simple:
Create an empty repository on GitHub, let's call it github-project
Clone from Heroku, let's call it heroku-project
Add a remote for github
Push to GitHub
The commands to perform these steps:
git clone git#heroku.com:heroku-project.git
cd heroku-project
git remote add github https://github.com/github-username/github-project
git push -u github master
That's it!
Note: if you already created the GitHub project with a README file in it, then it is NOT empty anymore, and the last push will be refused. In that case you can force the push, effectively overwriting the project on GitHub, by using the --force flag, for example:
git push -u github master --force