💾 Archived View for gmi.noulin.net › mobileNews › 134.gmi captured on 2021-12-05 at 23:47:19. Gemini links have been rewritten to link to archived content

View Raw

More Information

➡️ Next capture (2023-01-29)

-=-=-=-=-=-=-

Re:how to learn git?

Re:how to learn git?

(Score:5, Informative)

by Anonymous Coward on Saturday June 02 2007, @11:28PM (#19368025)

set up new project

cd project

git init

git add .

git commit -a -m "Initial commit"

edit a file

vi file.php

git commit -a

add a file

vi new.php

git add new.php

git commit -a

see the log

git log

make a branch

git branch working

git checkout working

or in one step

git checkout -b working

add some changes to this branch

vi file.php

see what you changed

git status

check it in

git commit -a

see all branches

git branch

go back to the first branch (initial branch is called "master" by default)

git checkout master

make some other changes

vi other.php

git commit -a

merge the working branch into this one

git merge working

see the branches and merges in a graphical browser

gitk --all

let's do a log of all commits in "working" that don't exist in "master"

git log master..working

hmm let's undo that last merge (tip of branch is HEAD, one commit back is

HEAD^.. we are "popping" one commit)

git reset --hard HEAD^

push your changes out (push the tip of local "master" branch to remote

"incoming" branch)

git push foo.bar.com:~/myrepo master:incoming

pull changes from another repo (remote "feature1" into local "feature1"

branch)

git pull baz.bar.com:~/otherrepo feature1

move the branch point of the "working" branch to the top of the "master"

branch

git checkout working

git rebase master

It can get a LOT more complex of course.

When you're starting out, just remember "git commit -a" and you'll be fine.

Also check out "git reflog" to see the linear history of your repo. The pulling

/pushing stuff can get a lot more complex but it's damn powerful. If you can

figure out Arch (yeesh) you can figure out git!

SLASHDOT SEZ: you have too few characters per line. Okay, slashdot, here's part

of the man page for git-rebase:

If is specified, git-rebase will perform an automatic git checkout before doing

anything else. Otherwise it remains on the current branch. All changes made by

commits in the current branch but that are not in are saved to a temporary

area. This is the same set of commits that would be shown by git log ..HEAD.

The current branch is reset to , or if the --onto option was supplied. This has

the exact same effect as git reset --hard (or ).If is specified, git-rebase

will perform an automatic git checkout before doing anything else. Otherwise it

remains on the current branch. All changes made by commits in the current

branch but that are not in are saved to a temporary area. This is the same set

of commits that would be shown by git log ..HEAD. The current branch is reset

to , or if the --onto option was supplied. This has the exact same effect as

git reset --hard (or ).If is specified, git-rebase will perform an automatic

git checkout before doing anything else. Otherwise it remains on the current

branch. All changes made by commits in the current branch but that are not in

are saved to a temporary area. This is the same set of commits that would be

shown by git log ..HEAD. The current branch is reset to , or if the --onto

option was supplied. This has the exact same effect as git reset --hard (or ).