-
Notifications
You must be signed in to change notification settings - Fork 4
Workshop0
Have you ever had the experience of loosing a file you're working on? Fed up of copying or emailing a file for the boss or a group of you are working on to find out there are now several different copies? Have a work in progress where you need to go back to an older version if things break?
Version control is like printing out a copy on paper every time you save, if you make a change and you need to go back you can easily go back in time, it's all there, from everyone.
When working in a team, 20 people can change the same file and constantly save, but sometimes, you need to Blame someone, especially when things break.
Welcome to making your life easier, welcome to a new beginning.
Github is a great online repository built around Git, very user friendly and they offer a great service for free and the paid support is only if you choose to either support them, or have private repos.
If you wish to push your changes to xinchejian and share back to the community, you might want to consider over a secured connection as your name is on everything you do. Here is how on Github:
- Go to http://github.com and sign up for an account, it takes just a few minutes.
- inside your github account go to Account Settings > SSH Public Keys > Add Key Give it a name like "xinchejian" and then paste your RSA public key in here
Git does not litter your root folder with a .git folder.
git clone git@github.com:xinchejian/XinCheJian-Workshops.git
This will give you a local copy of the XinCheJian workshop files checked into the github account.. this is everyones so watch out it might grow big later.
Create a folder in XinCheJian-Workshops/Android/Participants/{yourname}/ add a readme file inside your participant folder You can got back to the root directory and add everything not in version control, or individually as you need to:
git add .
your changes are only added to the queue, lets commit them with: git commit .
Up pops your text editor, in here enter a short descriptive message of what you've done, this is invaluable if you ever have to dig back through your history.
What do you think the following does?
git push
Correct: it pushes the changes upstream, in this case github.
Next, update your local files with changes from upstream (github)
the opposite of push is?
git pull
Lets personalize Git a little, lets set our name and email address into our commits to look a little better to others:
git config --global user.name "Firstname Lastname"
git config --global user.email "your_email@youremail.com"
Dont have your Private key on your work computer and dont want it there either? Github has your back.
Login to your github account > Account Settings > Account Admin > copy your API Token for the following command
git config github.user github-username
git config github.token api-token
If you leave your job or get worried, you just need to change your github password and your API-Token will change leaving your account inaccessible from that computer.
Go back to your working directory, and create an empty file named .gitignore inside this file add the following:
.DS_Store?
Thumbs.db
Great, no more Mac or Microsoft droppings, unless! they have already started to be tracked.. that sucks!
git rm --cached .DS_Store* Thumbs.db
and remember to: git commit . git push
add a few more if you've got binary blobs so we dont waste space
bin/*
*.com
*.dll
*.exe
There are many more but see the resources at the end of this page.
There is a bug that exists in eclipse on OSx preventing you from successfully cloning a Repo so we'll go through another way which i my mind is more efficient.
Window > Open Perspective > Other > Git Repository Browsing
-
Copy this:
git@github.com:xinchejian/XinCheJian-Workshops.git
-
Now in the new panel press "Clone a Git Repo.." (middle of the 3 Git icons)
-
Hit next and use master
-
hit next and specify a location and remote name should be master not origin (keep it simple)
-
hit next and it'll start to pull down the files.
-
Right click the new Repo and press
Import Projects > Import as General Projects
and it's done, it should now be in your Resource perspective.
In the Git Repository Browsing select the Repo then move down to the properties window (or right click open properties view) Select "Repository Configuration" in the drop down menu and change it to "Global Configuration" hit the open button on the right of that.
Here we can add our Name and Email address to identify us.
"Add a new Entry" and enter user.name for the key and your name for the value "Add a new Entry" and enter user.email for the key and your address for the value.
Done.
It's important that we don't confuse Eclipse, so if you edit files on the File System directly then right click the Folder and refresh to reload the folders content. Make some changes like create a folder under Android/Participants/{your name here}/ and add an empty file named readme through the right click menus.
When ready, right click the folder > Team > Commit and list out all the files you want to commit and hit.. Commit
Now they are Committed locally we need to push them upstream, right click the Project folder > Team > Push to Upstream.
Remember to commit and pull often, push is at your own cost.