You need a GitHub account and a version of Git up and running on our Linux PC.
Open a shell and execute:
git config --list
to see the current git configuration, probably you will see default name and email or nothing(I start taking my experiment over an existing configuration).
Configure Git
To configure Git using this statements:
git config --global user.name = aStrangeName
git config --global user.email = myemail@somedomain.boh
The name identifies the user during commits. If you have GitHub account you should specify the related email in order to push there your commits.
Note that this is a global configuration, you can override it for a specific project executing the same statements (omitting the --global option) from within the working directory of that project. For example, to prevent spam you can define a fake user email from the GitHub website and use it in your working directory.
Create a repo
Create a repo in the current directory is pretty simple:
git init
Commit
In order to test commit and push you need to add some file to the list of the ones you want commit:
git add <fileToAdd>
You may want execute
git status
to see what happened in your working directory. In this case you will see <myfile> as a staged file.
git commit -m "comment for commit"
Execute the commit and associate the specified message. After this command you can verify that git status assert that no pending files remain.
Push
Now it's time to interact with your GitHub repo.
First create a new repo: a GitHub repo should be created from remote only using the API, the git command cannot do this. For this operation you can use the API through a url-manager like curl or you can access more easily your account and create a new repo from the web interface.
Then define a remote repo with:
git remote add origin https://github.com/<mygithubuser>/<mygithubrepo>.git
(you will find the correct url in your GitHub page for the repo).
A git standard propose to use the name origin for the remote that point to the main repo.
Now you are ready to send your files to the remote repo:
git push origin master
Note that GitHub requires that your git version is equals or greater than 1.7.10. Attempting to push something with an old version will give you a http 403 error.
These are only my notes about git, you will find more interesting info at GitHub
bootcamp page.
Nessun commento:
Posta un commento