Howto git PART 1

How to do things, solutions, recipes, tutorials
Message
Author
gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#16 Post by gyro »

MochiMoppel wrote:The next problem: Now that I have committed my change, I can't edit the file any longer. I would like to add another change. How can I do this? Uncommit? The pencil icon which let me make the first change is not active anymore... :cry:
Sorry, don't know, never done editing or commits directly on github.
gyro

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#17 Post by mavrothal »

MochiMoppel wrote: The next problem: Now that I have committed my change, I can't edit the file any longer. I would like to add another change. How can I do this? Uncommit? The pencil icon which let me make the first change is not active anymore... :cry:
You just change the file and make another commit. There is no problem one change to be done in multiple commits. It's actually recommended! A pull requests can have multiple commits. :wink:
Alternatively you can revert the commit and start again, but you do not gain anything by this because at the end will be 3 commits. Original, reversion and the new one.
Plan C is to do hard reset (git reset --hard <commit hash>) to a previous commit that will both change the files and the commit log to a previous state. This is actually not recommended because you really lose all the info from that point forward.
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#18 Post by MochiMoppel »

mavrothal wrote:You just change the file and make another commit.
But this was exactly my problem: can't do that. It turned out that this is a browser issue. I switched from Opera to Seamonkey, which - surprisingly - gives me a different tooltip for the right pencil icon (Something like: you have to choose a branch first). In Opera it's "make changes to the file" and the branch default can't be changed and is set to a cryptic number. "master" sounds a bit bold, but I hope it's OK.

So a "commit" is what? Just a copy of the original files with my changes?
Plan C is to do hard reset (git reset --hard <commit hash>) to a previous commit that will both change the files and the commit log to a previous state.
I wouldn't know how to do this online.
Attachments
Screenshot.png
(77.82 KiB) Downloaded 330 times

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#19 Post by MochiMoppel »

So many unanswered questions, so many wasted hours, so much frustration. I've deleted all of my test projects, I'm on the brink of giving up on github.

OK then, one last try. Step-by-step:

I forked woof-CE to MochiMoppel/woof-CE
From now I operate in the master branch of my forked version.
My goal is to make a change to 1 file, then issue a request to pull this change into the testing branch of the original woof-CE . Is this the correct approach?

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#20 Post by rufwoof »

MochiMoppel wrote:So many unanswered questions, so many wasted hours, so much frustration. I've deleted all of my test projects, I'm on the brink of giving up
Fortunately I didn't waste too many hours before losing interest and giving up.

stemsee

#21 Post by stemsee »

You should operate in the 'Testing' branch.

Actually I gave up with github, for the present.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#22 Post by MochiMoppel »

stemsee wrote:You should operate in the 'Testing' branch.
Fine, but how do I copy the file I'm going to work on from my copy of the master branch to my copy of the testing branch? Fork a single file? Issue a pull request to myself? Or can I assume that all files in the testing branch are the same as in the master branch? Would defeat the purpose of keeping a testing branch...

stemsee

#23 Post by stemsee »

Copy the contents of the file. Then move to the same subdir in Testing and create new file then paste into it.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#24 Post by MochiMoppel »

I would consider this to be the equivalent of shutting down the computer with the power button or eating with your fingers at the Queen's banquet dinner ... you can do it, but shouldn't. I would expect that git provides a better way, which doesn't break the audit trail and which would assist me in cases where I have to copy not just 1, but 100 files.

gcmartin

#25 Post by gcmartin »

This is NOT going to answer any of your questions; BUT it may be a source(s) of getting correct use approaches:Hoping this will help

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#26 Post by mavrothal »

Unless you want to do limited editing to a file, I would NOT use the browser to do any git work. Github is more of a server for your files than an actual work environment
Git has almost limitless abilities (and thus options...) Only a small fraction of these is available through the web interface of github.

So, fork, clone your fork to your machine, work on your local machine anyway you want (there are git-GUIs for any OS if you need it), commit your changes in your local machine, push to your repo and at that point when you are happy with YOUR git/github state, use the web browser to issue the pull request.
Regarding having a pull request between different branches, is not advised as down the road is likely to mess up the history if/when branches will be merged (there are ways around it too, but is a hassle).
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#27 Post by MochiMoppel »

mavrothal wrote:Unless you want to do limited editing to a file
Yes, I want to do limited editing to a file. I clearly described what I did and asked for the next step. Let me worry about the "limitless abilities" later and kindly advise how I can achieve this seemingly trivial task in the browser.

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#28 Post by mavrothal »

MochiMoppel wrote:
mavrothal wrote:Unless you want to do limited editing to a file
Yes, I want to do limited editing to a file. I clearly described what I did and asked for the next step. Let me worry about the "limitless abilities" later and kindly advise how I can achieve this seemingly trivial task in the browser.
I have seen several things here. Which one are you referring to?
Copy a file form master to testing? Merge the versions of a file in the two branches(does it exist in both)? Do (whatever it is you want) in the browser mandatorily and not in your local machine? Solve the browser compatibility issues? Other?...
A better question may get you a better answer :wink:

In general you can "merge" branches, or "cherry-pick" specific commits.
You probably want to merge master into testing. There are many options that can overcome specific issues in merging. A search with the warning (if any) will likely give you the solution if a problem arrises.
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#29 Post by MochiMoppel »

mavrothal wrote:I have seen several things here. Which one are you referring to?
I wrote: I forked woof-CE to MochiMoppel/woof-CE
From now I operate in the master branch of my forked version.
My goal is to make a change to 1 file, then issue a request to pull this change into the testing branch of the original woof-CE . Is this the correct approach?

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#30 Post by mavrothal »

MochiMoppel wrote:
mavrothal wrote:I have seen several things here. Which one are you referring to?
I wrote: I forked woof-CE to MochiMoppel/woof-CE
From now I operate in the master branch of my forked version.
My goal is to make a change to 1 file, then issue a request to pull this change into the testing branch of the original woof-CE . Is this the correct approach?
Can be done but better work in the same branch you want to issue the pull request at
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#31 Post by MochiMoppel »

Translation: Wrong approach. Good. We are making progress.

Now I have 2 options:
a) Stay in my master and change the file and issue pull request. Easiest way.
b) Get the file somehow into my testing branch and issue pull request. Difficulties already explained.

I prefer option a)
May I go ahead with a)?

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#32 Post by mavrothal »

MochiMoppel wrote:Translation: Wrong approach. Good. We are making progress.

Now I have 2 options:
a) Stay in my master and change the file and issue pull request. Easiest way.
b) Get the file somehow into my testing branch and issue pull request. Difficulties already explained.

I prefer option a)
May I go ahead with a)?
You can but is wrong.

Merging master into testing is as simple as

Code: Select all

git checkout master
git pull --all #make sure you are current with the repos
git checkout testing
git pull #to update it
git merge master --no-commit # so you can make needed changes
#resolve any conflicts by adding removing files by 'git add' or 'git rm' <file>
git commit -am "merge master into testing"
git push #to update the repos with the local changes
Done!
Now whatever it was added or changed in master and not in testing after the point of their diversion, is added/changed into testing too.
Whatever was deleted in master and not in testing will be deleted in testing.
Whatever was added in testing and not in master stays in testing.
Master stays as it was.
If a file was modified in testing and deleted in master or vice versa, after the point of diversion, you may have a conflict and your need to decide which way to go (keep the modified file or delete it).

You may have other conflicts depending how procedural you are with your committing, but are usually all solvable.

In general when merging, changes that happened only in the branch that you merge in will be transferred in the branch that you merge into, including their commit history. When the same file is changed simultaneously in both branches you have a conflict. Even if it is the same change!
That is why is a better idea to work in another branch (say, testing) and only when you are happy with the changes and feel they are mature enough you merge back into your master.
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#33 Post by MochiMoppel »

OK, I went ahead with plan b)

mavrothal, please understand that your perception of 'simple' and mine are very different. I know that this seems very simple for you as you do this on a daily basis and anyway need more powerful tools than the web interface can offer, but for mere mortals like me, whose modest aim is to change a few lines of code in a textfile that is displayed right in front of me in the browser, what you describe seems to be total overkill. You said yourself that the web approach is possible for simple tasks, so let's do it. Don't scare well-minded and reasonably patient users like me away by setting entry hurdles that are too high.

I now made some very minor changes to the file installpkg.sh in my testing branch and issued a pull request in the main testing branch. At least this was my intention. Please let me know if this worked. If it did, I will add some bug fixes for the same file.
There was only one thing that irritated me: In the header it said "MochiMoppel wants to commit 272 commits into master from testing". Well, I made only 1 commit in testing and I don't want to commit anything to master. Should I worry? The pull request queue shows only the pull request that I initiated, so it looks OK to me.

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#34 Post by mavrothal »

MochiMoppel wrote:OK, I went ahead with plan b)

mavrothal, please understand that your perception of 'simple' and mine are very different. I know that this seems very simple for you as you do this on a daily basis and anyway need more powerful tools than the web interface can offer, but for mere mortals like me, whose modest aim is to change a few lines of code in a textfile that is displayed right in front of me in the browser, what you describe seems to be total overkill. You said yourself that the web approach is possible for simple tasks, so let's do it. Don't scare well-minded and reasonably patient users like me away by setting entry hurdles that are too high.

I now made some very minor changes to the file installpkg.sh in my testing branch and issued a pull request in the main testing branch. At least this was my intention. Please let me know if this worked. If it did, I will add some bug fixes for the same file.
There was only one thing that irritated me: In the header it said "MochiMoppel wants to commit 272 commits into master from testing". Well, I made only 1 commit in testing and I don't want to commit anything to master. Should I worry? The pull request queue shows only the pull request that I initiated, so it looks OK to me.
Actually using the web interface is something I did only 2 or 3 times! So I'm the wrong person to advise on its full potential, but I did use pull reuest :)
So coming to your pull request, I did see it and rejected it (you should have a mail by now) because, what you actually tried to do was to commit your testing branch to the woof_CE master branch. Thus the 272 commits. You should compare your testing branch with the woof-CE testing with testing branch and issue the pull request on their difference, that should only be the file you changed.
Here is a short and simple guide in case I'm not clear enough (as usually...)
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#35 Post by MochiMoppel »

OK, second attempt. Looks better, though I can't quite remember how I revived my commit.

My problem in my first attempt was that I couldn't figure out how to create a pull request from my account, then switched to the main account and saw 2 promising buttons to create a pull request and surely I selected the bigger of the two. Seemed to be logical since I want to pull into the main account. If I would be operating in my own account this would be more like a push. So in all there are 3 buttons and 2 are wrong...I'll try to learn.

I keep my fingers crossed.

Post Reply