-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Git Commands on how to create a new repository, branch out and work on a release then merge to main.
1.) Create a new project repository in Github via UI and then use git to add, change and commit code.
- Use Mac terminal to go in the folder where the project files are and run following commands
Initialize a git repository
$git init
Add the files (git add . for all files)
$git add
$git commit –m “comments” **Get the URL of the remote repository from Github ** $git remote add origin
$git push origin master (if error then fetch and merge)
$git fetch origin
$git merge origin (also used git push origin master –-force)
Create a branch release1.1
$git checkout -b release1.0
Switched to a new branch 'release1.0'
$git push origin release1.0
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/enatech/python-aws-code.git
- [new branch] release1.0 -> release1.0
Check which branch you are on
$git branch
master
- release1.0
Make changes to you files in your branch in local repository then push the changes
$git commit -a -m "Test"
[release1.0 5dbb916] Test
2 files changed, 1 insertion(+)
delete mode 100644 .s3.py.swp
$git merge release1.0
Already up-to-date.
$git push origin release1.0
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 280 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To https://github.com/enatech/python-aws-code.git
436d700..5dbb916 release1.0 -> release1.0
Now merge the release1.0 to master
$git checkout master
Switched to branch 'master'
$git merge release1.0
Updating 436d700..5dbb916
Fast-forward
.s3.py.swp | Bin 12288 -> 0 bytes
s3.py | 1 +
2 files changed, 1 insertion(+)
delete mode 100644 .s3.py.swp $git push origin master
All changes are now in sync with master branch
2.) Make a new branch and add code via release 1.2
$git checkout -b release 1.2
Switched to a new branch 'release1.2'
Make changes to the files and then commit. If adding a new file
$git commit -m "New ELB file" -a
[release1.2 85c0c21] New ELB file
1 file changed, 39 insertions(+)
create mode 100644 elb.py
*Now push the code to Github, but fetch to make sure nothing to merge
$git fetch origin
$git merge release1.2
Already up-to-date.
$ git push origin release1.2
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 1.11 KiB | 0 bytes/s, done.
Total 6 (delta 3), reused 0 (delta 0)
To https://github.com/enatech/python-aws-code.git
- [new branch] release1.2 -> release1.2
Merge to main
$git checkout master
Switched to branch 'master'
$ git merge release1.2
Updating 5dbb916..1603330
Fast-forward ec2.py | 6 ++++-- elb.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 elb.py
*Finally push to master $ git push origin master
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/enatech/python-aws-code.git 436d700..1603330 master -> master