תרגול 2
תרגול 2
$ mkdir testProject
$ cd testProject
$ git init --initial-branch=main
$ git status
$ touch README.txt
$ git status
$ git add README.txt
timelin
$ git status e
$ git commit -m “Create a README”
$ git status
main
Version Control (VC) - The Structure, Workflow
main
Git Diff
this command will show you all the changes that are in the working
directory and not the staging area. meaning that after “git add .” you
won’t be able to view those changes.
BRANCHING
pizza
$ git branch
pizza HEAD
* main
main
BRANCHING
pizza
HEAD
$ git checkout pizza
$ git branch
* pizza
main
main
BRANCHING
pizza
HEAD
$ git add pizza.txt
$ git commit -m “Tasty pizza”
$ ls
README.txt pizza.txt LICENSE
main
BRANCHING
pizza
main
BRANCHING
pizza
HEAD
$ git checkout pizza
$ls
README.txt LICENSE pizza.txt
main
main
● Create a branch
● Change code.cs in branch
● Merge: conflict
● Fix conflict via text editor
● Add & commit
main
Clean Up
*main indicates the name of the branch. You can also use:
$ git push -u origin --all
Collaboration
Collaboration
● Temporary branches
● Can be many feature branches being developed in
parallel
● If the feature is a failure
○ Delete the branch without merging into develop
Pull requests
“Pull requests let you tell others about changes you've pushed to a branch in a
repository on GitHub. Once a pull request is opened, you can discuss and review
the potential changes with collaborators and add follow-up commits before your
changes are merged into the base branch.” - Git documentation.
Locally merge VS Remote pull requests
The invariant of the base branch, or in Git case the main branch, is that the base
branch is always finished, meaning that it does not hold unfinished features, code with
bugs, or code that does not compile.
Therefore in this course We will Save Pull Requests just for merging finished feature
branch to the main, while merging a feature branch to another feature branch can be
done with local merging.
In addition, before we pull request branchA into develop, we first merge develop into
branchA.
Note: In your project, If a team member A opened a pull request from a feature branch
to the main, in no circumstances team member A is allowed to approve the pull request.
it needs to be reviewed and approved by other team members.
erge
m
pull
requ
e
st
Ignoring Files
● Example:
● https://www.toptal.com/developers/gitignore
GIT TIMELINE HISTORY
$ git log
commit e5c36be744223ef3789d870d12ea6bf676360248
Author: goolig <[email protected]>
Date: Wed Jan 30 10:48:19 2019 +0200
:
Add katz notebook
:
commit b6954141cba3962478bca1c83954ea25486742a1
Author: goolig <[email protected]>
Date: Wed Jan 30 09:55:26 2019 +0200
:
_Add preproc pickles
:
Additional Tutorials
● https://www.w3schools.com/git/default.asp?remote=github
● If any contradictions with class appear, refer to the class material
as the ground truth.
● There are many other good tutorials available.