Friday, September 30, 2011

Git resolve merge conflicts

So you have

$git merge repo
Auto-merging path/to/file1
Auto-merging path/to/file2
CONFLICT (content): Merge conflict in path/to/file3
Auto-merging path/to/file4
CONFLICT (content): Merge conflict in path/to/file5
Automatic merge failed; fix conflicts and then commit the result.

To fix:

For all files with conflicts, do:
1.vim path/to/file3 and then compare the text

<<<<<<<

=======

with

======

>>>>>>>
Make sure you delete those indicator lines too.

2. git update-index [path/to/file3]

source

Sunday, September 25, 2011

Github as the second remote

This is a brute-force way of setting up github as a second remote/backup to your code.

1. $ cp -r repo repo_backup
2. $ cd repo_backup and then vim .git/config
delete the old [remote "origin"]
3. $ git remote add origin git@github.com:username/repo_name. Now you should see its corresponding lines in .git/config
4. I want to push my local branch "b1" to a branch on github named "branch1", so I did git push -u origin b1:refs/heads/branch1

multiple git remotes

One is the real git remote, one is a backup I would like to have on github.


==============
.git/config's remote fetch = +refs/heads ...
explained here


Finally,
fetch = +refs/heads/*:refs/remotes/origin/*
That means if you do
git fetch origin
It will actually do:
git fetch origin +refs/heads/*:refs/remotes/origin/*
Which means a remote heads/foobar will be local remotes/origin/foobar, and the plus sign means they'll be updated even if they are not fast-forward.

answered by felipec

================
http://stackoverflow.com/questions/849308/pull-push-from-multiple-remote-locations/849960#849960

Thursday, September 15, 2011

error: expected expression before ')' token

Maybe you have an extra comma at the end of your list of arguments. ;)

C programming compare pointers to numbers

You want to check if a particular pointer is at an address.
If the pointer is of uint32_t* type, trying to make an address in in uint32_t might throw you this error: error: this decimal constant is unsigned only in ISO C90.
Here is what you can do:
uint32_t* ptr;

ptr = get_it_some_how();
cprintf("  get the int of address: %08d \n", ptr);
 
int* target = (int *)  -267296968;  // this is the int you copy from the printout above

if( ptr == (uint32_t*) target )       // look! a cast!
    cprintf(" yay the pointer is at target!\n");
else
    cprintf("  noo! the pointer is not at target\n");

Friday, September 9, 2011

git edit commit message and push to github

Steps to edit a git commit message and also have it show up to Githb:

1. To edit your last commit message:

git commit --amend

2. Edit your commit message on top. If you're using vim, to save and quit, do esc+":wq"

3. Push to Github:

git push --force


Note that if you don't have the "--force", you'll get this error message:

$ git push
To git@github.com:your/repo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:your/repo.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.
So remember to git push --force!