Can anyone give me some guidance on how to use Git, so that I can further read the manuals. Now the manuals is too complicated for me.
I am using an opensource code, I am not the core developer, but I am also developing some modules in my field. But the core team wont accept my development. I hope I can keep an backup of all my modifications and new added modules in a repository or something like that, and I can see them on github. But in the meantime, I want to keep on updating all the unchanged the files from the core developers, and if there is a conflict or the file, I want to simply keep mine.
So, should I create a new branch, or create a fork, or create a new repository?
For example, after I git clone blahblah and some days later, I git pull to uodate, and then I modified a file-A, and added a new dir B and a file C under B. What should I do now? Because whenever I git pull again, there is a warning error saying some files are in conflict.
update of my question:
Thanks, this is very helpful.
Please correct me if I am wrong, what I need to do now is:
-
Go to the github, and make a fork of the original project repo. Does this mean I am creating a new repo under my account?
-
Then, there will be a git link address with this new repo, is that right?
-
And then I just on my computer use, git clone this_new_git_repo_link to copy the whole project.
-
Add or modify on my own computer, and learn to commit all the changes,
-
then these changes will be seen from online github through my new repo.
-
When the upstream, there is a change, on my own computer, I create a new branch called the “upstream”?? The original one that was copied from my own fork repo will be by default called “master”,
-
then switch to branch upstream by using command checkout, and then execute ‘git pull’, and this will create two versions on my own computer now, one is the updated version, and the other is my modified version.
-
Here the question is how to merge this updated branch “upstream” into my own branch “master”, what is the command to just merge those files I have never changed. And so that after stwitch back to my own branch of “master”, I can do a commit, so my online repo will be both with upstream update and my own modifications.
If you and the other developers are using github, then I would fork the main repo and set it as the upstream. You can then work in your own master branch and push and pull your own work as much as you like. If the upstream branch changes and you want to pull in the changes, you might consider making a new branch to easily mark where you are at (you can always delete this branch later), then switch back to the master branch and then pull in upstream changes to your master branch. You might get merge conflicts, but git will mark these in the files in your master branch. If you don’t like the core developers changes, you can delete all, or some of the conflicting code they added and then keep woking as normal.
You can keep repeating this cycle indefinitely so that you stay relatively up to date with the core.