Home > git_experiments

git_experiments

Git_experiments is a project mainly written in ..., it's free.

  • Create a local empty Git repository using $ git init .

  • Add this README file $ git add README $ git ci

  • Add a directory called A with a file call A/file1.txt with one line in it $ git add A $ git add README $ git ci

  • Created a repository on Github called szabgab/git_experiments and then followed the instructions: $ git remote add origin [email protected]:szabgab/git_experiments.git $ git push origin master After that added these lines to the README file and pushed them out again: $ git add README $ git ci $ git push

  • Add another file called TODO where I list the use case I would like to check out $ git add . $ git co

  • The above would have caused a problem if I was doing it while this file is open in vim as there is a .swp file So create .gitignore and add *.swp in it. Now I can safely use $ git add . $ git ci -m'gitignore swap files'

  • Create a branch. In the branch create a new file A/file2.txt, add the new file The branch could be created any time. Before the changes or during the changes or after I finished them. $ git co -b dev $ git add A/file2.txt $ git ci

  • Make another change to the same file $ git add A/file2.txt $ git ci

  • Go back to master branch, create another branch, make some changes to file1 and commit them $ git co master $ git co -b other $ git add A $ git ci

  • go back to master and commit the changes to this README and to the TODO file $ git co master $ git add . $ git ci

  • In the meantime using we can observe the various branches in the local repository: $ gitk --all

  • While on the master branch merge the other branch and push it out $ git merge other $ git push = What is disturbing me that now I can see the same change twice. I can see the change both as it was originaly done and under the title "Merge" as well.

  • Delete the local branch that was merged and is not needed any more: $ git branch -d other

  • On another machine create a clone: $ git clone [email protected]:szabgab/git_experiments.git A_git $ cd A_git $ gitk --all

    we can see all the earlier branches but they only reveal their original name in the Merge comment

    edit the README file and the .gitignore file (add *~)

    $ git add README $ git ci $ git co -b big

    make changes to A/file2.txt

    $ git add Afile2.txt $ git ci

    switch to the master and make some changes there

    $ git co master $ git add .gitignore $ git ci $ git push # being on master the two changes on master get pushed $ git co big

    edit README

    $ git add README $ git ci

  • push the big branch to the remote repository $ git push origin big

  • in the other local clone run $ git pull $ gitk --all

    observe the big branch here too, you can switch to it

  • in the regular local clone while on branch big:

    change README

    $ git add README $ git ci

  • merge from master $ git merge master

    make some changes to README

    $ git add README $ git ci Apparently now that we have already pushed big once it is enought to type $ git push

    and it will be pushed again

Previous:Swithon