Add remote via JGit

I playing around JGit, I could successfully remove a remote from some repository (git remote rm origin), how can I do a git remote add origin http://github.com/user/repo ? To remove I do the following: StoredConfig config = git.getRepository().getConfig(); config.unsetSection(“remote”, “origin”); config.save(); But there’s no a option like #setSection(String, String). Thanks in advance.

Does Git work in Windows?

I work on Linux all the time and I’m clueless about Windows, not even having a Windows box. Is Git nowadays working on Windows? Or am I making problems for my Windows pals by using it?

How do you organize your git repositories?

“Traditional” version control systems follow a “Cathedral” model — all the code is stored in one main repository. Distributed Version Control Systems like git allow a lot more flexibility in organizing your multiple repositories. You can “push” changes, “pull” changes, and “clone” repositories. Have you organized your repositories along your workgroup or workflow lines? Have […]

“Updates were rejected because the tag already exists” when attempting to push in SourceTree

When attempting to Push via Source Tree, I get the following error: git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v –tags origin refs/heads/master:refs/heads/master Pushing to https://user@github.com/repo.git To https://user@github.com/repo.git = [up to date] master -> master … ! [rejected] example_tag -> example_tag (already exists) updating local tracking ref ‘refs/remotes/origin/master’ error: failed to push some refs […]

git aliases causing “Permission denied” error

The following commands $ git co -b newbranch $ git co oldbranch result in “fatal: cannot exec ‘git-co’: Permission denied” error. In the same time, $ git checkout -b newbranch $ git checkout oldbranch and $ sudo git co -b newbranch $ sudo git co oldbranch work as expected. Ownership rights for the .git folder […]

Git: removing a file from being versioned, but not deleting it

I have a file which ended up being versioned in our repository but shouldn’t have been. For arguments sake, the file is config.py. We instead version config.py.tpl but never the actual production config for the obvious reasons. What’s the right way to stop versioning this file without deleting it locally from the working directory? Also […]

Adding Git to PATH Variable – Can't find GitHub under AppData/Local

I was following this guide here on how to add Git to my Path variable so I can use it from the command line (Not just Git Bash). Installing Git in PATH with GitHub client for Windows To quote an answer, Git was supposedly located here Get the Git URL We need to get the […]

Git enumerates nonexistent untracked files slowly

I am using git for source control on a repository. Recently it has begun warning me about how long it takes to enumerate untracked files when using git status: $ git status On branch my_branch Changes not staged for commit: (use “git add <file>…” to update what will be committed) (use “git checkout — <file>…” […]

Moving git submodule to another directory within the same repository

Initially I had the following (simplified) repo structure: MyRepo external1/MySub (git submodule) .gitsubmodules Where $ cat .gitsubmodules [submodule “external1/MySub”] path = external1/MySub url = user@repo:/remoterepo/externals/MySub.git I then wanted to move MySubmodule to another directory in the same git repository, e.g., external2 so the structure is as follows: MyRepo external2/MySub (git submodule) .gitsubmodules What I did, […]

git switch branch without discarding local changes

Alright, lets say one day we make happen to make a bunch of modifications and when we go to commit them we notice we were working on the wrong branch. How can we force git to switch branches without discarding local changes. I’m probably going to go about this in a naive way while I […]

Git Baby is a git and github fan, let's start git clone.