Please enable JavaScript.
Coggle requires JavaScript to display documents.
Git & Github (Branching (Tracking remote branches (local .git will…
Git & Github
Branching
Creating own copy of a branch (typically master) which you can then merge back into master subject to approval
-
-
-
-
-
Update Git branches from master
1.git checkout b1
2.git merge origin/master
3.git push origin b1
or alternative:
1.git push origin b1
2.git rebase origin/master
-
You can create a new branch whilst being in a new/different branch: git checkout <NEW BRANCH><BRANCH TO BRANCH FROM>
e.g. git checkout transaction master
New branch is rejected - need to update latest changes of current branch with remote branch in github: `git pull origin <NEW FEATURE BRANCH>
Tracking remote branches
local .git will manage branches but to check its synchronisation with remote branches add -r
flag: git branch -r
-
-
-
Starting, Purpose and Concepts
-
-
-
-
Cloning - clone a repo to copy all files onto local machine to test or amend
git clone <CLONE URL>
or
git clone <CLONE URL> <NAME OF NEW DIRECTORY>
The new files will go in the current directory you are in
Start Github from the command line:
:star: echo "#<FOLDER-NAME>" >> README.md
:star: git init
- starts a git folder in your app which will be uploaded
:star: git add README.md
or git add .
:star: git status
:star: git commit -m "first one"
:star:git remote add origin [url]
(Url is http://github.com/username/foldername.git)
:star: git remote -v
- verify the new remote Url
:star:git push -v origin master
- add -f
to force it or -u
Workflow
- Feature Request ->
- branch ->
- add code,commit and push ->
- merge master request ->
- pull request ->
- code reviewed and messages between colleagues
Don't necessarily deploy the code on github but good place to store and work with others - setup a deploy strategy using the code in Github (auto push)
-
-
-
-
Origin is not the remote repo name - it is a local alias set as a key in place of the remote repo URL - avoids user having to write whole remote URL .
Name is set by default but can be changed with
git remote rename origin mynewalias
Commands
-
-
-
-
-
Update and Publish
-
-
Add new remote repository named <remote>
git remote add <shortname><url>
e.g. git remote add origin http://github/path/to/project/online
-
-
-
-
Merge and Rebase
-
-
-
-
-
Use editor to manually solve conflicts and mark file as resolved
git add <resolved file>
git rm <resolved file>
-
Local Environment
Add all files to Git file on local environment "git add ."
or git -A
(The full stop means all files in this directory)
Commit Files to Github on local environment: git commit -m <MESSAGE>
- must give message commenting what the commit is about otherwise will go into a vi editor(ESC :wq
to exit)
Push to Github - update Github online with Git from local environment: git push <name> <branch>
e.g. git push origin master
-
Pull Requests
-
Workflow for pull requests:
- make sure latest version of feature branch from remote repo:
git checkout <BRANCH>
git pull origin <BRANCH>
- Make sure feature branch is up to date with master
git pull origin master
:star: any conflicts address here
- Now feature branch is up to date with remote repo and that it has the latest code from master - can merge branches
git checkout master
git pull origin master
git merge --no-ff <NEW FEATURE BRANCH>
:star: --no-ff keeps the repo branching hisotry from flattening out - set it as default
git config --global merge.ff false
4 Delete feature branch
git branch -d <FEATURE BRANCH>
(can't delete a branch you have checked out)
If an error force delete with -D
- Delete branch from remote repo:
git push origin --delete feature-branch
-
-
-