|Excluding certain file types from a pre-commit hook|
# A git hook script to find and fix trailing
# in your commits. Bypass it with the --no-verify
# to git-commit
# usage: make a soft link to this file, e.g., ln
LIST="md txt c cpp"
for i in $LIST
if [ "$i" = "$1" ]
|GIT - Get CruiseControl NET to Push to Origin|
You have commitBuildModifications and tagOnSuccess
turned on, so any changes would be committed
during the 'publish' of the build. There would be
no need to change your configuration.
The change would only be committed in the event of
a successful build
The change would be committed after the build, not
If any of the following tasks fail the
change/increment would not be committed.
|Github- How can I find unpublished branches on my local machine?|
Look at this question: Viewing Unpushed Git
You should be able to use git log to get your
git log --branches --not --remotes
To look for unmerged branches: git finding
git branch --no-merged master
|How to move manually versioned files to git (version control)?|
Yes, you can. You can use the following script:
for i in $(ls -1tr)
cp "$i" myfile
git add myfile
COMMIT_MESSAGE=$(echo "$i" | cut -d '-' -f2)
COMMIT_DATE=$(echo "$COMMIT_MESSAGE" | sed -E
git commit -m $COMMIT_MESSAGE
Keep in mind that ls output should not be p
|Git branching strategy for Agile project|
it sounds to me like, you are very close to
choosing Git Flow. Actually, if I'm not mistaken,
this is already your base from the strategy, you
describe. Which is great.
I'm hearing your main concern is, that you want a
non-release "develop" branch, sort of like a "just
trying stuff out, might not compile"
environment/branch. Git flow indeed favours a
"flow" towards production. I.e. once anything
|How would I automatically execute a git pull after a commit?|
If you are using bitbucket this link suggest good
solution,I used it and it is very good.
|Bash Script for PHP Lint always returning 0|
For testing purposes, I have php -l stored in a
variable $STUFF and have it return what if the
return status of php -l is 0
That's not what your code says. Your code stores
the output of php -l and then compares that with
0; the return status of a command is stored in $?.
And as always you can check for a non-zero return
status directly in if.
if php -l ...
|How do I push additional branches to Stash?|
If those are actual local branches (visible when
you type git branch in the repo), then, following
"using branches in Stash", you should see those
branches in the branches field:
If your stash displays a remote repo (not your
local repo on your machine), then you would need
to push those 2 branches on your remote repo
first, before Stash is able to detect them.
git checkout my-branch-one
|git rebase -i foo/dev gives noop|
Your git log command is showing commits that are
on ajryan/dev but not on temp-a. Your rebase
command is told to rebase commits that are on
temp-a but not on ajryan/dev, but presumably there
are no such commits. Pictorially:
... - o - o - o <--
o - o - o - * <--
Therefore, there are no commits to pick up and r
|Is it safe to abort during "git fetch"?|
It should be safe.
git fetch will first simply transfer new objects.
After everything is downloaded it will set the
remote ref to the new head commit. If you abort it
during the download step it has nothing changed at
to all the refs yet. Therefore everything should
|git ~/.config/git/config not reading|
Ok, after reading this question about including
files, I came up with this simple solution to make
git aware of the configuration file in a different
Add this line to your system file (/etc/gitconfig)
path = $HOME/.config/git/config
sudo git config --system include.path
This solution makes git config -l w
|Git, ignore all files except a few in subdirectories|
If you have a *, you'll drop all
If you have /*, you'll drop all directories and
files at top level.
It looks like what you really wanted was:
|How to override unmerged git checkout with upstream version|
You might need to reset the file first, before
doing the checkout:
git reset -- Jovie/Jovie-Info.plist
git checkout -- Jovie/Jovie-Info.plist
The reset un-stage the changes in progress (here
the merge, with the conflict markers in the file).
Then the checkout can restore the index with the
last commit content.
|Switching current work in master branch to a new branch (in git)|
git stash (to save the work in progress on master)
cherry-pick your commits from master to feature-x.
See "How to cherry pick a range of commits and
merge into another branch".
reset master to an older commit.
checkout feature-x and git stash pop, for your git
status to get back all the current changes
That assumes that all your last commits on master
were for feature-x
|Can I restrict uploading certain file extension in github.com?|
Add the following line to the .gitignore file at
the root of the project:
and commit the file. Then git will ignore those
See How Can I Remove .DS_Store Files From A Git
Repository? for how to remove the already
committed .DS_Store files.
|Change name under project activity on gitlab based on git config user.name|
What you want is currently not possible.
GitLab determines which GitLab user you are, and
then prints out your GitLab username.
I think that makes sense, since all those
usernames link to your profile, so it would be
surprising to have two different display names
linking to the same profile.
The best workaround I can think of is to create
two different GitLab users. Doesn't it make more
|tips with git for private repo|
git add and git commit do run within any folder of
your local git repo.
Please note the difference between git add and git
add -A or git add -u.
git status operates only in a local repo, a
non-bare one, meaning one with a working tree
checked out. (See "concept of bare shared
repository in git" on bare repos)
git pull and git push uses by default the remote
named 'origin': see "Git Basics - Work
|Locally "forking" a git repo|
Either process should work for what you are
As for whether they are the same thing, they are
very similar but copying (cp -r) will result in
keeping the current branch setting whereas cloning
(git clone) will put you back on the HEAD branch.
Cloning will still fetch other branches and you
can still use git checkout to switch back on to a
This probably won't matter much cons
|Using git for a project with 2 lines of development|
I prefer to use a release branch and a hotfix
branch, maybe you already know git flow
For me it is the best way to keep the code under
In other hand, in your case I use to isolate api
related calls to avoid api changes to impact too
much in the development.
|TFS build definition associated commits|
So I've likely been down voted as I could use git
to do it all, but a comment pointing that out
would've been nice.
As I'm brand new to git I missed the fact I can
create a tag and use that in place of the commit
id and then run up to the HEAD version to get all
commits between them
git log <last tag>..HEAD --format="%ci - %cn
- [%h](<path to my TFS>/commit/%H) %s%n"
|Roll back project using Git (Force pull?)|
You'll use git reset --hard
So if you're working on master then the remote
branch is origin/master, simply
git fetch origin
git reset --hard origin/master
|Clone link not matching the external_url with GitLab-Omnibus installation|
I had exactly the same problem. Little bit of
search leads me to this page,
Which suggests to change the external_url in your
file /etc/gitlab/gitlab.rb like below,
It is perfectly working for me with Omnibus
Installer of GitLab-7.5.3 on Ubuntu 14
|Pushing git repo to digitalocean ubuntu 12 server|
What's the dir structure in your repository
If your git repo does not have a html top level
dir, then create it and clone the files out into
git clone <path to repo>
This assumes your files in the repo are:
|Problems with maven release on git|
I think it is because of
It should be fixed in 2.5. However see the comment
I used this plugin configuration
|Pushing dist subtree to GH-Pages|
I found a nice shell on github that does this:
However, I'm always open for an inline answer :)
|What's the difference between git "--track" and "--set-upstream-to"?|
$ git checkout foo -b
$ git branch --track origin/retarget
The first two commands instruct git to:
create a local branch named "origin/retarget"
(very bad idea, as it is named as a remote
tracking branch", while it is actually a simple
local branch with a '/' in its name)
starting from the current branch ("foo", another
to make that new local branch tracking its
|Git hook for whenever HEAD changes|
It seems like it may not be possible (though
please prove me wrong), so I have settled with
this good-enough approach: I trigger the script
from a number of hooks, which means that it will
be run most of the time.
These are the hooks that I am using:
|GitHub error "fatal: bad config file line 1 in .git/config" when in git shell|
My question might have been abit vague, but I
wasnt sure myself what happened. I solved it by
finding .git/config file on my laptop using
Windows search , and deleting it. Then I deleted
content of my github folder and cloned the repo
again and it worked after :)
|Managing Go dependencies on git|
You should look at Glide.
Glide provides simplified Go project management,
dependency management, and vendoring.
Glide basically changes your $GOPATH on the fly
and keeps copies of your dependencies in a local
structure instead of the global structure that is
customary for a standard Go environment.
|Git: I've a feature branch with 80+ commits. How can I safely merge it into develop/production without ruining the history?|
The general aproach is
Split the mixed feature commits
Reorder the commits
I assume that your repository looks like this
A B C D
and that your feature changes are mixed and
- feature 1 changes are in A,B,C
- feature 2 changes are in A,C,D
- feature 3 changes are in B,C,D
Split the commits
If you want to bring the chan
|git branch -r vs git remote show origin|
The git branch command looks at (or, invoked
differently, modifies) your own repository's
information. For remote-tracking branches (git
branch -r), this shows what's in your cached copy
of what was on the remotes the last time you had
your git contact those remotes and get updates.
The git remote show name command, by default, runs
git ls-remote, which actually calls up the
remote's server over
|Clearing sensitive information when running "git commit"|
The standard (and correct, really) advice is to
keep those passwords elsewhere, e.g., read them
out of a different, not-version-controlled, file
(~/.netrc and so on).
That said, you could use a pre-commit hook to
check for a password in the index1 and abort the
commit if present (this is again standard advice:
don't modify things in pre-commit hooks, just tell
the user that there's something not
|Team City + Git SSH agent-side checkout. : Need SSH_KEY error|
The issue was on Unfuddle side. Now the fixed it
and it works great.
Here is the thread at JetBrains support:
|git hangout when i run 'git add .'|
The .swo file isn't tracked by git (unless you
already added it in the past), this is why you
can't use git rm (which only tells git to stop
tracking the files).
You just don't want to stage it when using git
add, and you have two ways to do that:
Giving only the files you really want to stage to
git add (instead of of .)
Writing *.swo to your .gitignore file (which you
can create if it doesn't
|Is it possible to create a warning when pushing to a specific (i.e. live) git source?|
You could use git's pre-push hook.
You can learn more about hooks here, and you
likely have example scripts installed with your
git distribution (or even in your repo!)
|What advantages: git clone versus source install?|
When you install a software from source there are
Get the latest code in archive (usually .tar.gz)
from maintainers website. Usually maintainers put
their latest release code in download section. You
download, extract, compile and install. Its the
recommended for users.
Doesn't contain bleeding edge features and bug
Get the latest code
|git best practice - how to separate development from testing and deployment|
As you probably know git is a bit different than
svn in how things are done.
There are as many opinions on how to do things as
there are developers.
If you wan't to go open source then I suggest to
read up on strategies from numerous open source
Since you say "my repo" I'm guessing no one else
will push to it.
A simple strategy is to keep development on
branches that pushes to master.
|Different repositories for each module in intellij IDEA|
Go to Settings/Version Control, there you can
configure different VCS roots per directory. So in
your case define one VCS root per directory
containing the module. You should remove the VCS
entry <Project> and just add entries for
individual modules so that it looks something like
If you have files modified in several different
repositories and hit CTRL+K or otherwise open the
|How to add parent directory to git repo|
If your repository should only contain the proj
folder with nothing else at the same level, then
the proper way to do it is to make proj the
repository. You do that by following those
instructions, i.e. calling git init within the
That way, when people clone your repository, they
automatically get a folder with the same name as
the repository which then contains all the stuff.