git

HEAD detached from origin/master

Everything starts with a problem trying to checkout your repository master branch:

git checkout master
error: pathspec 'master' did not match any file(s) known to git.

Trying to checkout origin does not improve things, but at least is a step forward:

git checkout origin/master
Note: checking out 'origin/master'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at d1389fef9... Merge pull request #4

Now, problem, your master branch is detached in your local.

Solution, create a new branch from that state:

git checkout -b temp

And point master to that new branch

git branch -f master temp

Now you can push to your origin branch to update also in github or your remote repository.

categorias: 

Using git in bitbucket without password

Look mom, without hands...

First, change this in your .git/config:

old url:

 url = https://[email protected]/hispamedios/PROJECT.git

new one:

url = ssh://USER.bitbucket.org/hispamedios/PROJECT.git

 

Edit your .ssh/config, in your local directory, and add this:

 cat .ssh/config
Host YOURUSER.bitbucket.org 
HostName bitbucket.org 
User git
IdentityFile ~/.ssh/bitbucket

The last line is important, so you are indicating your identity file. Now create this file:

ssh-keygen -f .ssh/bitbucket -C "YOURUSER"

And now test it. Go to your local repository, do smart changes in your code and commit them or simply do a "git pull". It should not ask you for password anymore.

categorias: 

Deploying Drupal projects: git + capistrano

 

removing some folders from git, file .gitignore with these contents:

 

# Ignore paths that contain generated content.

cache/

files/

sites/*/files

sites/*/private

 

 

 

Using symbolic links for /files directory:

 

 

namespace:custom do

    task:symlink do

      run "ln -s /var/www/crucerista/sites/crucerista.net/files/ /var/www/crsta/current/sites/crucerista.net/"

      run "echo 'finished'"

    end

end

after "deploy","custom:symlink"

 

 

Related links:

Similar technique, but aplied to Rails apps: http://www.practicalecommerce.com/blogs/post/468-Creating-Symlinks-When-Deploying-a-Rails-Application

Another idea, File Transfer actions in Capistrano: http://www.simonecarletti.com/blog/2009/02/capistrano-uploads-folder/

 

error: unable to create temporary sha1 filename ./objects/17: Permission denied

I have had this issue recently, with a git branch which did not want to to react to push. That's what a was having:


$ git [email protected]'s password Counting objects: 5, done.
Delta compression using up to 2 threads.
ng objects: 100% (3/3), done.
Writing objects: 100% (3/3), 303 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
error: unable to create temporary sha1 filename ./objects/17: Permission denied
fatal: failed to write object

error: unpack failed: unpacker exited with error code
[email protected]:/var/www/git/domain
! [remote rejected] HEAD -> master (n/a (unpacker error))
error: failed to push some refs to '[email protected]:/var/www/git/domain'

The problem is a permissions one... but it will not work if you try to update the permissions in the server folder. You have to update the permissions in the server, but in .git folder:

chown -R git:git .git/

In my case git was the user who should have the permissions to write.

Once changed, the push in your local environment should work.

categorias: 

git Mini Howto

All you need to know to start faster in Git:

  • sudo git add .
  • sudo git commit -m "function findFriends added"
  • git push -u origin master

That's it :-)

categorias: 

some git commands

 

 

try.github.com

sudo git reset --hard origin/8.x

issue summary template: http://drupal.org/node/1155816

http://core.drupalofficehours.org/

http://drupal.org/project/dreditor  --> for chrome/firefox

 

Novice tags are good for starting to contribute.

 

Applying a patch in Drupal core:

1. Download the patch,

2. apply: git apply -v [patch]

 

 

categorias: 

Upgrading two git repositories automatically

There is a simple way of upgrading or executing a command immediatly after a push has been done.

We just need to go to the server repository (the one which is going to receive the push), and enter in hooks (.git/hooks or hooks if it's a bare repository).

Then, we rename the post-receive.sample to post-receive, without extension, and add this content:

echo "********************"

echo "Post receive hook: Updating User Staging"

echo "********************"

cd ../live

GIT_DIR='.git'

git pull origin master

echo "********************"

echo "Post receive hook: Updating User Staging"

echo "********************"

You'll just have to change the ../live path with the place where your live git code lives, and the next time you make a commit, the live directory will be automatically updated with a git pull.

It is not the perfect way of going live, is my case this is a staging server, so it's fine. If you need to go to "real" live, Capistrano is what you are looking for. We'll speak about it next weeks.

categorias: 

git Integration Manager Workflow tutorial

 

IN BLESSED

mkdir gitlab/blessedrepo

cd gitlab/blessedrepo

git init

 

Creating new files:

vim README

adding:

git add .

git commit -m "first file in blessed repository"

git push

 

IN DEVELOPERS

mkdir developer2

cd developer2

git clone /Users/air/gitlab/blessedrepo

ls

blessedrepo

ls blessedrepo/

README

cd blessedrepo

vim fileindev2.html

git add .

 

 

MacBook-Air-de-Air:blessedrepo air$ git commit -m "added file by developer2"

[master 422f2e5] added file by developer2

 1 file changed, 2 insertions(+)

 create mode 100644 fileindev2.html

MacBook-Air-de-Air:blessedrepo air$ 

 

 

get changes from main repository:

 

MacBook-Air-de-Air:blessedrepo air$ git pull

Already up-to-date.

MacBook-Air-de-Air:blessedrepo air$

 

 

Getting changes from a developer. In Blessedrepository, we execute:

 

 

MacBook-Air-de-Air:blessedrepo air$ git pull /Users/air/gitlab/developer2/blessedrepo/

.git/                 fileindev2.html       thirdfileindev1.html  

README                secondfile.html       

MacBook-Air-de-Air:blessedrepo air$ git pull /Users/air/gitlab/developer2/blessedrepo/

remote: Counting objects: 4, done.

remote: Compressing objects: 100% (2/2), done.

remote: Total 3 (delta 0), reused 0 (delta 0)

Unpacking objects: 100% (3/3), done.

From /Users/air/gitlab/developer2/blessedrepo

 * branch            HEAD       -> FETCH_HEAD

Updating d3bb3f1..422f2e5

Fast-forward

 fileindev2.html | 2 ++

 1 file changed, 2 insertions(+)

 create mode 100644 fileindev2.html

MacBook-Air-de-Air:blessedrepo air$

 

 

Now, Blessedrepository has the new files:

 

MacBook-Air-de-Air:blessedrepo air$ ls

README secondfile.html

fileindev2.html thirdfileindev1.html

MacBook-Air-de-Air:blessedrepo air$ 

Now, developer1 wants to get changes in main Repository:
MacBook-Air-de-Air:blessedrepo air$ git pull
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /Users/air/gitlab/developer1/publicrepo/../../blessedrepo
   21f5117..422f2e5  master     -> origin/master
Updating d3bb3f1..422f2e5
Fast-forward
 fileindev2.html | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 fileindev2.html
MacBook-Air-de-Air:blessedrepo air$

 

Now, test conflicts. dev 1 and dev2 edit the same file, 

 

 

MacBook-Air-de-Air:blessedrepo air$ git add .

MacBook-Air-de-Air:blessedrepo air$ git commit -m "added by dev1"

[master 80f7afa] added by dev1

 Committer: Air <[email protected]>

Your name and email address were configured automatically based

on your username and hostname. Please check that they are accurate.

You can suppress this message by setting them explicitly:


    git config --global user.name "Your Name"

    git config --global user.email [email protected]


After doing this, you may fix the identity used for this commit with:


    git commit --amend --reset-author


 1 file changed, 2 insertions(+)

MacBook-Air-de-Air:blessedrepo air$ 

 


 

 

Developer 2, the same:

 

 

MacBook-Air-de-Air:blessedrepo air$ git add 

Nothing specified, nothing added.

Maybe you wanted to say 'git add .'?

MacBook-Air-de-Air:blessedrepo air$ git add .

MacBook-Air-de-Air:blessedrepo air$ git commit -m "changes by dev2 in same file"

[master 20b26a8] changes by dev2 in same file

 Committer: Air <[email protected]>

    git commit --amend --reset-author

 1 file changed, 2 insertions(+)

MacBook-Air-de-Air:blessedrepo air$ 

 

 

Time to pull changes from developer1 and 2 in Blessed Repository:

 

MacBook-Air-de-Air:blessedrepo air$ git pull /Users/air/gitlab/developer2/blessedrepo/

From /Users/air/gitlab/developer2/blessedrepo

 * branch            HEAD       -> FETCH_HEAD

Already up-to-date.

MacBook-Air-de-Air:blessedrepo air$ git pull /Users/air/gitlab/developer2/blessedrepo/

remote: Counting objects: 5, done.

remote: Compressing objects: 100% (2/2), done.

remote: Total 3 (delta 1), reused 0 (delta 0)

Unpacking objects: 100% (3/3), done.

From /Users/air/gitlab/developer2/blessedrepo

 * branch            HEAD       -> FETCH_HEAD

Updating 422f2e5..20b26a8

Fast-forward

 secondfile.html | 2 ++

 1 file changed, 2 insertions(+)

MacBook-Air-de-Air:blessedrepo air$ 

 

 

and from the other developer (where we expect the conflict):

 

MacBook-Air-de-Air:blessedrepo air$ git pull /Users/air/gitlab/developer1/publicrepo/blessedrepo/

remote: Counting objects: 5, done.

remote: Compressing objects: 100% (2/2), done.

remote: Total 3 (delta 1), reused 0 (delta 0)

Unpacking objects: 100% (3/3), done.

From /Users/air/gitlab/developer1/publicrepo/blessedrepo

 * branch            HEAD       -> FETCH_HEAD

Auto-merging secondfile.html

CONFLICT (content): Merge conflict in secondfile.html

Automatic merge failed; fix conflicts and then commit the result.

MacBook-Air-de-Air:blessedrepo air$ 

 

 

RESOLVE CONFLICTS

git mergetool

 

 

 

categorias: 

private git repositories in bitbucket

Let me got directly to the point. The bitbucket documentation is wrong, on the begining you are just suposed to do a git remote add origin

in the directory which you want to commit. But this will not work:

fatal: Not a git repository (or any of the parent directories): .git

Solution? Init the repository:

git init

git remote add origin https://[email protected]/ACCOUNT/REPOSITORY.git

git push -u origin master

will also don´t work :-(. The problem is that the message error is all but obvious.

 

error: src refspec master does not match any.

error: failed to push some refs to 'https://[email protected]/ACCOUNT/REPOSITORY.git'

 

But, think... we need to have something to commit before sending this "thing", don't we?

Then:

git add .

git commit -m "first commit with all the contents

And, finally, we send the commits with the changes in our code:

git push -u origin master

 

remote: bb/acl: hispamedios is allowed. accepted payload.

To ....

 

Nice, isn't it?

categorias: