Git for dummies like me
Installation: Check this link.
Clone a respository
- Get the clone link:
The link would look something like this: https://github.com/hunglvosu/subsetTSP.git
- Creat a local folder, point to it and type git clone https://github.com/hunglvosu/subsetTSP.git. A folder name "subsetTSP" will be created, like in the following figure:
- Now you are ready to make changes, add files or do whatever you want to the folder. Any change you make will just be local changes, and nobody can see your changes except you, unless you "commit" the change to the online repository by following the instructions below.
Note: Before making any change, you should pull the most updated version of the online repository to your local, because other people may change the folder before, by typing: git pull.
After making local changes, you can commit your changes to the online repository by following the steps below:
- Type git status to see changes that you have made. In the following figure, I have made change to the file name subset-tsp.tex in my local repository.
- Type git add . to add all the changes for committing. Note that the dot is importan to have. This essentially tells git that "I've added changes, now I ready to commit the changes". If you don't want to add all changes, but just some files, say a.tex and b.tex, you can type git add a.tex b.tex instead.
- Type git commit -m "Message to describe the change" to commit. This tells git that "I'm committing to my change". Still, nobody sees the change yet, except you. In the message, you can write whatever you want, but it should be something to remind you of what you have done, just in case you want to revert the change later in the distant future.
- Type git push origin HEAD to push the changes to the online repository. After this, everybody will see the change. No need to do anything else.
Add files to the repository
- Simply copy the files to your git local repository.
- Type git status to see the files you have added. In the following figure, I add two files to my local git repository.
- Type git add . to add all the changes for committing. If you just want to add some of the files, then you need to type all the file names instead of dot, as in commiting changes.
- Type git commit -m "dd two files latex8.sty and latexmac.sty" to commit.
- Type git push origin HEAD to push the change to the online repository.