-
Notifications
You must be signed in to change notification settings - Fork 1
Little Git Howto
This wiki page is entitled to new developpers of the project and assume push rights on the repository, if you don't, please fork the project and make a pull request.
This howto also asume you already installed and configured git (if not see this page )
First, in order to get a working copy of the repository you need to clone the repository, so open a console in the directory you want to have your copy and then, all you have to do is :
git clone https://[email protected]/GP-S/HOTS.git
Now you have your copy of the project, you can freely edit the files.
According to this legend, you have done some work on your local repository, so you need them to be watched by git. If you didn't add any files then no worries you can jump to the next paragraph. So you have to add the files you added in order to have git following them. This is simply done by :
git add [My Files]
If you try to add an empty directory it won't work and that is normal (anyway why would anyone do that).
Now all the files you want to be followed are added, you can check what files have been modified since the previous commit using git status
or you can proudly commit your changes using git commit -a
.
At this point you will have to write a wonderful message to explaine your modifications, the first line is the summary of the commit and needs to give a general overview of what the commit does.
The message needs to be quite precise about what you changed, or to be more precise about what the commit does, considering the fact we are using github, you can reference issues in commit using its number preceded by #
and the commit message will be added as a comment on the issue and the two linked (you can close an issue in a commit by using the terminology fix #xx
with xx
the number of the issue).
Well this command is a bit special as it gets the changes made on the remote repository to apply those on your local repository, if you have done modifications then there are two cases:
First: you commited all your changes then no problem you can safely use this command.
Second: you didn't commit your changes, if so you have multiple solutions, commit these (see previous episode), stash your changes or discard your changes. To discard your changes do git clean -df
. To stash your changes (save your changes without commiting them) do git stash
(theses commands are so complicated)
Once you have no uncommited files (stashed files don't count as uncommited files) you can pull from the origin by simply using git pull
Now your local repository is up to date, if you stashed some files you can unstash them using git stash apply
. (if some files don't merge correctly see the episode 5)
Now you are up to date with the origin, you can push your changes to the origin, this is one of the simpler part as this is simply done by git push
. But as you might only look at this part if you have a problem with this command here are the common errors you can encounter:
- The local repository is not fast-forward: simply pull the origin before pushing again
If some vilains have modified files while you were also modifying theses and git didn't managed it by itself, then you have to manually merge the files, in order to do that, I send you to this well done how-to: Well done how-to
Time has come my friends, you have to create a new branch (or delete a branch or navigate between branches)
Well jump is not the most relevant term, you actually checkout a branch (or any commit) using git checkout [branch name|commit hash]
you first have to delete the local branch using git branch -d [name of branch]
the delete the remote one using git push origin --delete [name of the branch]
To merge two branches, first get into the branch you want the branch to be merged in then do git merge [branch-name]
To create a new branch one can simply use git branch [name of the branch]
and here it is, you can then checkout this branch or if you want to do these operations at once use git checkout -b [name of branch]