Creates a merge commit combining remote + local work
Visual example
Before:
After:
Where M is a merge commit between C head from remote and E head from your commit so M was a merged result of C & D, E.
When to use it
Shared branches with many contributors
When rewriting history is not allowed
When you want to preserve the exact order of events
When your team explicitly requires merge commits
Downsides
History becomes noisy
Merge commits pile up
Harder to read
Harder to bisect
How to check if your local git is default –no-rebase or configured to –rebase
git config list
user.name= my name user.email=my.name@gmail.com pull.rebase=true core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true remote.origin.url=git@github.com:chanvichekaouk/catch2-hpp-unit-test.git remote.origin.fetch=+refs/heads/:refs/remotes/origin/ branch.main.remote=origin branch.main.merge=refs/heads/main branch.main.vscode-merge-base=origin/main
or retreive value of specific config:
git config --get pull.rebase
if it shows true then yes it is configured to –rebase.
show empty or false then yes it is default to –no-rebase
How to set it to –rebase by default
For all repositories:
git config --global pull.rebase true
For just this repo:
git config pull.rebase true
e.g here initially my local git is set to default –no-rebase so you can see the deviation of the line as it is a merge btw remote head and my local commit since then I have configured global to –rebase so my history log will be a linear line which as pointed out would be easy to read.
First of all, go to Amazon AWS and create our free AWS account and saved its private key.
Once we login to our aws console, we can search ec2 and since I have visited it before here I will just click on EC2
Then click on Launch instance
We are going to use Amazon Linux
Ok it launched successfully. Then click on its instance name guid as seen above “i-075f2…”
Note down the ip address since we are going to connect to it using our saved private key. we will use our private key “MyLinux.pem” to connect to it which matched with its public key at Amazon AWS server.
At Command prompt execute:
We are now connected with our Amazon AWS EC2 instance.
Note the user name is always ec2-user for amazon linux OS.
I am going to execute Linux update with yum update command:
but we do not have the privilege to do it so we will have to elevate ourself to root with following command sudo -i
We are now root so we should be able to upgrade our Linux to its latest repo with
yum update
That looks good. our AWS linux instance is update to date with its Kernel repo.
git is not installed yet so we will have to install it with yum install git
yum install git
type y to proceed
Git install is completed
Next we will create a directory called mylinuxrepo
Check if it is created with ls -l
cd to our mylinuxrepo directory and issue git status
it is not a git local repo yet so we will have to convert it to local git reposity with git init
Now check agian with git status
Ok now it is a local git repo. let create a bash script called addcal.py using vi editor
Press i for insertion mode (writing mode)
press esc (for mode) and type :wq (w mean write and q mean quit) to write and quit
addcal.py is created and let execute it with bash addcal.py
Good our bash script is working.
Note: Also my bad it is not a python script and accidentially naming it .py but it does not matter the name.
Good, next we will stage it and commit it
Note that I forgot to set the git config –global user.name and git config –global user.email
Next, we will have to link it to the central distributed remote repo aka GitHub
Note, also authentication in linux with username, password would not work and we would have to use personal access token.
Ok now connect our local repo to remote repo in GitHub
Here when authentication through https with username/password would never work here in Linux so we will have to use token
Go to your GitHub profile and setting and click on Developer settings
Click on Token (classic) and click Generate a new token
Checked repo and Click Generate token button at the buttom
Copy the token and saved it to somewhere secured
Now let try to add our local git repo to remote git hub repo:
When prompt with Password, past the copied token and here we now successfully link and push our local change in our local git repo to the remote github repo:
Note: I have to delete this token after this post 🙂