Synchronize your project with github

To synchronize your project (folder) with git hub, first check connectivity with them. Create an ssh key with your github mail (the mail that you use to login) and copy it in your github account. Later check the connection. Follow these commands:

apt-get install openssh-server
ssh-keygen -t rsa -C "nicolas.boettcher@mail.udp.cl"
cd ~/.ssh/
cat id_rsa.pub
#Copy this key to your github config
#Now, check connectivity to github
ssh -vT git@github.com

Now, create a new project on github page. To upload the content to github, follow these steps:

cd $FOLDER
git branch --set-upstream master origin/master
git config --global user.name "$USER"
git config --global user.email "$MAIL"
git init
#Now, add all files in your folder
git add *
git commit -m "$MESSAGE"
git status
git remote add origin https://github.com/$USER/$PROJECT_NAME
git push origin master

A common error is the following:

! [rejected]        master -> master (fetch first)
error: failed to push some refs
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

It's typicall because you have created a licence in github, but you don't have it on your local host.

Other common erros is the following:

 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

The solution is force the update. To do that, use:

git push -f origin master

When you will have a new code, just use:

git add $NEW_FILE
git commit -m "$MESSAGE"
git status
git push origin master

To avoid synchronize all files, you can create a .gitignore file, that contains files that are not public like:

#passwordfiles
*.pass
#private database
users.db

If you need remove files from the github use:

git rm -r --cached $FILE
git commit -m "Removed file from repository"

git push origin master

If you prefer use a GUI from nautilus, you can install a nautilus extension to manage your git:

sudo add-apt-repository ppa:rabbitvcs/ppa
sudo apt-get update

sudo apt-get install rabbitvcs-nautilus




Comments

Popular posts from this blog

Exception: Could not find a default OpenFlow controller in Mininet

How to fix Android when developer options are not available for this user

Webcam streaming throught VLC with YUY2 compatibility