Standard Git flows to follow

Initial setup

1| Clone the target repo in local

git clone

2| Fork the target repo

fork repo

3| Open terminal and rename the target repo alias, origin in local; say, upstream

git remote rename origin upstream

4| Add the previously forked remote repo in local

git remote add my-fork

5| Now, rename the forked remote repo alias in local

git remote set-url my-fork

6| Check remote versions

git remote -v

7| Observe both the upstream and forked alias in terminal

Rebase before every commit

1| Create a local branch, make changes to the codebase and check for the newly updated files

git status -s

2| Add all the required files for commit

git add --all

3| Create commit to the above-added files

git commit -m "your text"

4| And do git pull & rebase before pushing your changes to master. Cos, there might be additions in the original master that could cause possible conflicts with your newly modified scripts.

git pull upstream master --rebase

5| If found any conflicts, fix every conflicting file and check for status

git status -s

6| “Rebase continue” works only if all the conflicts are fixed locally

git rebase --continue

if not skip rebase

git rebase --skip

to abort rebasing,

git rebase --abort

7| Finally, force push the commit. You can even create multiple commits before push

git push -f my-fork users

8| The local changes are safely moved to your forked branch now. So, create a pull request to original master through GitHub interface. Happy Merging!!

Start with new branch

1| So far, we have seen how to ship local changes to upstream master through git rebase. And now, let’s have a plan to create separate branch locally to start with the new module. All we need is to fetch original/upstream master first,

git fetch upstream master

2| Create a local branch with the updated code from upstream master

git checkout -b new_branch_name upstream/master

3| Work on the newly created local branch and do rebase before every push

For details, Git Cheatsheet


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s