0% found this document useful (0 votes)
516 views24 pages

Git FLS Part 1 Intro

This document provides an overview and instructions for a training session on using Git. It outlines the topics that will be covered, which include cloning repositories, viewing commits, creating and committing changes on branches, code reviews, merging, rebasing and more. Attendees are invited to follow along on their laptops and instructions are provided for both Linux and Windows/Mac users.

Uploaded by

Rakshit Wadhwa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
516 views24 pages

Git FLS Part 1 Intro

This document provides an overview and instructions for a training session on using Git. It outlines the topics that will be covered, which include cloning repositories, viewing commits, creating and committing changes on branches, code reviews, merging, rebasing and more. Attendees are invited to follow along on their laptops and instructions are provided for both Linux and Windows/Mac users.

Uploaded by

Rakshit Wadhwa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Want to follow along on your laptop?

This is optional you may view the session without one To do so, youll need to have an Amazon laptop, and be online We are limiting access to commands that push to GitFarm

Sit in the designated area of Arizona 1.100/101 Everyone else will need to skip those particular steps
Preferably, ssh into a RHEL5 desktop, with SDETools OR, have Git installed on your Windows or Mac

Everyone following along will need to:

Friday Learning Series

Part 1:

Git for People Who Have More Important Things to Do Than Learn Git

Part 2:

Advanced Git: Unnecessary Surgery for Science

Part 3: Part 4:

Git: Escape From Planet Perforce

Git: Vox Populi

Git for People Who Have More Important Things to Do Than Learn Git

Friday Learning Series: Git, Part 1

Ground rules

Youre invited to follow along on your laptop


This is an experiment bear with us SSH into your desktop machine now Windows/Mac users need to have Git installed already We cant let everybody perform the push!

We intend to record this session We intend to keep things moving Raise your hand if you want assistance Didnt get to participate? Join git-training-interest@

What well cover today


Cloning a repository / adding a package to the workspace Viewing history (the DAG) Creating a branch Creating a commit Posting a review Publishing your finished code Sharing unfinished code with others Doing a merge Doing a simple rebase Recovering from mistakes and catastrophes

Add a package
Linux desktop users

brazil ws --create --name git-intro Performs a clone brazil ws --use -package GitIntroPart1_XX cd src/GitIntroPart1_XX

Other users

git clone ssh://git.amazon.com :2222/pkg/GitIntroPart1_XX cd GitIntroPart1_XX

Lets write something

git checkout Create a new file b my-branch t origin/mainline git add new-file.txt

Modify a file or two

git commit m Adding a new file git commit a

Lets see our commits


git git git git git git git git

status log -2 --amend commit config log -p --global color.ui true log -2 log --graph --decorate --all show

Post a code review

post-review --help

Linux desktop users

post-review \ --target-people= $NEIGHBOR post-review r 1409828

Other users

Wiki: Post-review (section: Command Line (postreview) )

How do you ship?

git fetch; git status

# OnMerge branch mainline your changes, if needed # Your branch and 'origin/mainline' have diverged, git status # and have 2 and 1 different commit each, respectively. # # On branch mainline nothing to commit, working directory clean # Your branch is ahead of 'origin/mainline' by 1 commit. # nothing to commit, working directory clean

git push

You are here

Server is here

Share your commit


git share -h

git share

Linux desktop users

Other users

git push origin HEAD:refs/share/$USER/ my-branch

Meet your neighbor


Linux desktop users

git add-share-remote $NEIGHBOR git fetch $NEIGHBOR

Other users

git fetch origin refs/share/$NEIGHBOR/*: refs/share/$NEIGHBOR/* https://w.amazon.com/index.php/Git/ GitAdvancedCommands#Using_Shares

Meet your neighbors code


git log --graph --decorate --all git diff checkout my-branch git origin/mainline git checkout neighbor $NEIGHBOR /my-branch git b neighbor git checkout push origin HEAD:$USER $NEIGHBOR/my-branch

What have we done?

http://code.amazon.com/packages/GitIntroPart1/logs https://devcentral.amazon.com/ac/brazil/directory/package/ branches/GitIntroPart1

Lets do a merge
Linux desktop users

cd .. brazil ws --use p GitIntroPart2 cd GitIntroPart2

Other users

cd .. git clone ssh://git.amazon.com :2222/pkg/GitIntroPart2 cd GitIntroPart2

Lets pretend
git git git git git git

log --graph --decorate --all branch feature1 origin/feature1 branch feature2 origin/feature2 branch d r origin/feature1 branch d r origin/feature2 log --graph --decorate --all

Lets do a merge

git git git git git git

Edit tpv.txt and resolve the conflicts

status add tpv.txt merge feature1 status status commit

See also: git help mergetool

That was easy


git git git git

show log --graph --decorate --all branch branch d feature1

This command is too long


git config --global alias.dag 'log --graph --decorate --all' git dag git dag --oneline

Lets do a rebase
git add checkout feature2 tpv.txt git git status rebase mainline git git rebase status--continue

git

Edit tpv.txt resolve the conflicts git dag and --oneline git git log diff --oneline mainline..

The great Undo feature


git git git git

reflog feature2 branch rescue f2b6c6d branch rescue feature2@{1} dag --oneline

Backups

git backup --all

Linux desktop users

Other users

git push --force origin refs/heads/*: refs/backup/$USER/*

Where do we go from here?

Gits data model The index The stash MUAHAHAHAHAHAAAA!! Interactive rebase Hooks Find bugs with bisect Filter-branch Fast-export, fast-import

For more information


For general Git questions: git@ For further training sessions: git-training-interest@ Keep an eye on the Git wiki page

Section For New Users

You might also like