Git(Hub) basic commands and usage

Create a local repository

Open your project folder in the chttp://www.albertcasadessus.com/wp-admin/post-new.phpommand line. Then:

git init
# to start a local repo
touch README
# Edit it, this file is required
git add .
# add all the files
git commit -m "first commit"
# do the first commit

Push it to GitHub

git remote add origin https://github.com/username/project-name.git
# create a remote repo
git push origin master
# push the commit/s to the master branch

Clone the repo to work on it from another computer

Open a terminal and go to the desired folder and:

git clone https://github.com/username/project-name.git
# now you have all the files in that computer, do all the changes
git commit -a -m "your commit text"
# commit all the changes
git push origin master
# push changes to GitHub

Update your local repo with the changes commited on github

git pull origin master
# to update the local files

Source:

Leave a Reply

Your email address will not be published. Required fields are marked *